Changeset 91312 in vbox for trunk/src/VBox/Main/include
- Timestamp:
- Sep 20, 2021 11:06:57 AM (3 years ago)
- Location:
- trunk/src/VBox/Main/include
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/ConsoleImpl.h
r90828 r91312 102 102 do { \ 103 103 if (!!(drv)) {} \ 104 else return setError(E_ACCESSDENIED, tr("The console is not powered up (%Rfn)"), __FUNCTION__); \104 else return setError(E_ACCESSDENIED, Console::tr("The console is not powered up (%Rfn)"), __FUNCTION__); \ 105 105 } while (0) 106 106 -
trunk/src/VBox/Main/include/ConsoleVRDPServer.h
r90828 r91312 61 61 62 62 /* Member of Console. Helper class for VRDP server management. Not a COM class. */ 63 class ConsoleVRDPServer : public VirtualBoxTranslatable63 class ConsoleVRDPServer 64 64 { 65 65 public: -
trunk/src/VBox/Main/include/DHCPConfigImpl.h
r90828 r91312 41 41 * can call setError and such on. 42 42 */ 43 class DHCPConfig : public VirtualBoxTranslatable43 class DHCPConfig 44 44 { 45 45 protected: -
trunk/src/VBox/Main/include/ExtPackManagerImpl.h
r90828 r91312 182 182 /* VBoxEventType_T */ uint32_t aType, 183 183 VBOXEXTPACK_IF_CS(IVetoEvent) **ppEventOut); 184 static DECLCALLBACK(int) i_hlpReservedN(PCVBOXEXTPACKHLP pHlp); 184 static DECLCALLBACK(const char *) i_hlpTranslate(PCVBOXEXTPACKHLP pHlp, 185 const char *pszComponent, 186 const char *pszSourceText, 187 const char *pszComment = NULL, 188 const int iNum = -1); 189 static DECLCALLBACK(int) i_hlpReservedN(PCVBOXEXTPACKHLP pHlp); 185 190 /** @} */ 186 191 -
trunk/src/VBox/Main/include/GuestDnDPrivate.h
r90828 r91312 800 800 * Class for keeping a DnD guest state around. 801 801 */ 802 class GuestDnDState : public VirtualBoxTranslatable802 class GuestDnDState 803 803 { 804 804 -
trunk/src/VBox/Main/include/GuestProcessImpl.h
r90828 r91312 214 214 * information extraction and maintaining the overall status. 215 215 */ 216 class GuestProcessTool : public VirtualBoxTranslatable216 class GuestProcessTool 217 217 { 218 218 public: -
trunk/src/VBox/Main/include/GuestSessionImplTasks.h
r90828 r91312 156 156 class GuestSessionTask 157 157 : public ThreadTask 158 , public VirtualBoxTranslatable159 158 { 160 159 public: -
trunk/src/VBox/Main/include/MachineImplCloneVM.h
r90828 r91312 28 28 struct MachineCloneVMPrivate; 29 29 30 class MachineCloneVM : public VirtualBoxTranslatable30 class MachineCloneVM 31 31 { 32 32 public: -
trunk/src/VBox/Main/include/MachineImplMoveVM.h
r90828 r91312 64 64 struct fileList_t; 65 65 66 class MachineMoveVM : public ThreadTask , public VirtualBoxTranslatable66 class MachineMoveVM : public ThreadTask 67 67 { 68 68 std::vector<ComObjPtr<Machine> > machineList; -
trunk/src/VBox/Main/include/TextScript.h
r90828 r91312 34 34 class AbstractScript 35 35 : public RTCNonCopyable 36 , public VirtualBoxTranslatable37 36 { 38 37 protected: -
trunk/src/VBox/Main/include/USBProxyService.h
r90828 r91312 43 43 */ 44 44 class USBProxyService 45 : public VirtualBoxTranslatable 46 , public Lockable 45 : public Lockable 47 46 { 48 47 public: -
trunk/src/VBox/Main/include/UnattendedInstaller.h
r90828 r91312 36 36 * execute an unattended installation 37 37 */ 38 class UnattendedInstaller : public RTCNonCopyable , public VirtualBoxTranslatable38 class UnattendedInstaller : public RTCNonCopyable 39 39 { 40 40 /*data*/ -
trunk/src/VBox/Main/include/VirtualBoxBase.h
r90841 r91312 364 364 { /* likely */ }\ 365 365 else \ 366 return setError(E_INVALIDARG, tr("Argument %s is NULL"), #arg); \366 return setError(E_INVALIDARG, VirtualBoxBase::tr("Argument %s is NULL"), #arg); \ 367 367 } while (0) 368 368 … … 377 377 { /* likely */ }\ 378 378 else \ 379 return setError(E_INVALIDARG, tr("Argument %s is an invalid pointer"), #arg); \ 379 return setError(E_INVALIDARG, \ 380 VirtualBoxBase::tr("Argument %s is an invalid pointer"), #arg); \ 380 381 } while (0) 381 382 … … 391 392 else \ 392 393 return setError(E_POINTER, \ 393 tr("Argument %s points to invalid memory location (%p)"), \394 VirtualBoxBase::tr("Argument %s points to invalid memory location (%p)"), \ 394 395 #arg, (void *)(arg)); \ 395 396 } while (0) … … 405 406 { /* likely */ }\ 406 407 else \ 407 return setError(E_INVALIDARG, tr("Argument %s is NULL"), #arg); \ 408 return setError(E_INVALIDARG, \ 409 VirtualBoxBase::tr("Argument %s is NULL"), #arg); \ 408 410 } while (0) 409 411 … … 419 421 { /* likely */ }\ 420 422 else \ 421 return setError(E_INVALIDARG, tr("Argument %s is an invalid pointer"), #a_bstrIn); \ 423 return setError(E_INVALIDARG, \ 424 VirtualBoxBase::tr("Argument %s is an invalid pointer"), #a_bstrIn); \ 422 425 } while (0) 423 426 /** … … 432 435 { /* likely */ }\ 433 436 else \ 434 return setError(E_INVALIDARG, tr("Argument %s is empty or an invalid pointer"), #a_bstrIn); \ 437 return setError(E_INVALIDARG, \ 438 VirtualBoxBase::tr("Argument %s is empty or an invalid pointer"), \ 439 #a_bstrIn); \ 435 440 } while (0) 436 441 … … 450 455 else \ 451 456 return setError(E_INVALIDARG, \ 452 tr("GUID argument %s is not valid (\"%ls\")"), #a_Arg, Bstr(a_Arg).raw()); \ 457 VirtualBoxBase::tr("GUID argument %s is not valid (\"%ls\")"), \ 458 #a_Arg, Bstr(a_Arg).raw()); \ 453 459 } while (0) 454 460 … … 465 471 else \ 466 472 return setError(E_INVALIDARG, \ 467 tr("Argument %s is invalid (must be %s)"), #arg, #expr); \ 473 VirtualBoxBase::tr("Argument %s is invalid (must be %s)"), \ 474 #arg, #expr); \ 468 475 } while (0) 469 476 … … 482 489 { /* likely */ }\ 483 490 else \ 484 return setError(E_INVALIDARG, tr("Argument %s %s"), \491 return setError(E_INVALIDARG, VirtualBoxBase::tr("Argument %s %s"), \ 485 492 #arg, Utf8StrFmt msg .c_str()); \ 486 493 } while (0) … … 497 504 else \ 498 505 return setError(E_POINTER, \ 499 tr("Output argument %s points to invalid memory location (%p)"), \500 #arg, (void *)(arg)); \506 VirtualBoxBase::tr("Output argument %s points to invalid memory location (%p)"), \ 507 #arg, (void *)(arg)); \ 501 508 } while (0) 502 509 … … 512 519 else \ 513 520 return setError(E_POINTER, \ 514 tr("Output argument %s points to invalid memory location (%p)"), \521 VirtualBoxBase::tr("Output argument %s points to invalid memory location (%p)"), \ 515 522 #arg, (void*)(arg)); \ 516 523 } while (0) … … 521 528 #define ReturnComNotImplemented() \ 522 529 do { \ 523 return setError(E_NOTIMPL, tr("Method %s is not implemented"), __FUNCTION__); \530 return setError(E_NOTIMPL, VirtualBoxBase::tr("Method %s is not implemented"), __FUNCTION__); \ 524 531 } while (0) 525 532 … … 562 569 #endif 563 570 564 /**565 * Parent class of VirtualBoxBase which enables translation support (which566 * Main doesn't have yet, but this provides the tr() function which will one567 * day provide translations).568 *569 * This class sits in between Lockable and VirtualBoxBase only for the one570 * reason that the USBProxyService wants translation support but is not571 * implemented as a COM object, which VirtualBoxBase implies.572 */573 class ATL_NO_VTABLE VirtualBoxTranslatable574 {575 public:576 /**577 * Returns translated text.578 *579 * @param aComponent Translation context e.g. class name580 * @param aSourceText String to translate.581 * @param aComment Comment to the string to resolve possible ambiguities582 * (NULL means no comment). Used by translation tool only.583 * @param aNum Number used to define plural form of the translation.584 *585 * @return Translated text.586 */587 static const char *translate(const char *aComponent,588 const char *aSourceText,589 const char *aComment = NULL,590 const int aNum = -1)591 {592 #ifdef VBOX_WITH_MAIN_NLS593 return VirtualBoxTranslator::translate(aComponent, aSourceText, aComment, aNum);594 #else595 RT_NOREF(aComponent, aComment, aNum);596 return aSourceText;597 #endif598 }599 600 /**601 * Returns source text stored in the cache if exists.602 * Otherwise, the @a aTranslation itself returned.603 */604 static const char *trSource(const char *aTranslation)605 {606 #ifdef VBOX_WITH_MAIN_NLS607 return VirtualBoxTranslator::trSource(aTranslation);608 #else609 return aTranslation;610 #endif611 }612 };613 614 571 //////////////////////////////////////////////////////////////////////////////// 615 572 // … … 624 581 const int aNum = -1) \ 625 582 { \ 626 return VirtualBoxTranslat able::translate(#cls, aSourceText, aComment, aNum); \583 return VirtualBoxTranslator::translate(NULL, #cls, aSourceText, aComment, aNum); \ 627 584 } 628 585 #else … … 718 675 */ 719 676 class ATL_NO_VTABLE VirtualBoxBase 720 : public VirtualBoxTranslatable 721 , public Lockable 677 : public Lockable 722 678 , public ATL::CComObjectRootEx<ATL::CComMultiThreadModel> 723 679 #if !defined (VBOX_WITH_XPCOM) … … 873 829 * Dummy macro that is used to shut down Qt's lupdate tool warnings in some 874 830 * situations. This macro needs to be present inside (better at the very 875 * beginning) of the declaration of the class that inherits from876 * VirtualBoxTranslatable, to makelupdate happy.831 * beginning) of the declaration of the class that uses translation, to make 832 * lupdate happy. 877 833 */ 878 834 #define Q_OBJECT -
trunk/src/VBox/Main/include/VirtualBoxClientImpl.h
r90879 r91312 106 106 #ifdef VBOX_WITH_MAIN_NLS 107 107 VirtualBoxTranslator *m_pVBoxTranslator; 108 TRCOMPONENT m_pTrComponent; 108 109 #endif 109 110 }; -
trunk/src/VBox/Main/include/VirtualBoxErrorInfoImpl.h
r90828 r91312 31 31 #ifndef VBOX_WITH_XPCOM /* IErrorInfo doesn't inherit from IDispatch, ugly 3am hack: */ 32 32 , public IDispatch 33 , public VirtualBoxTranslatable34 33 #endif 35 34 { -
trunk/src/VBox/Main/include/VirtualBoxTranslator.h
r90881 r91312 27 27 #include <VBox/com/AutoLock.h> 28 28 29 typedef void *TRCOMPONENT; 29 30 30 31 class QMTranslator; … … 46 47 47 48 /** 49 * Adds path containing translation files into list of known paths. 50 * Path should include translation file prefix. 51 * 52 * @returns VBox status code 53 * @param aTranslationPath Path to translation files including file prefix 54 * @param aDefault Use as default translation component, i.e. 55 * Use this path for translation if component 56 * is NULL 57 * @param aComponent Where is the pointer to component returned 58 */ 59 static int registerTranslation(const char *aTranslationPath, 60 bool aDefault, 61 TRCOMPONENT *aComponent); 62 63 /** 64 * Removes the path from list of known paths. 65 * Does not remove already loaded translation from string cache. 66 */ 67 static int unregisterTranslation(TRCOMPONENT aComponent); 68 69 /** 48 70 * Translates @a aSourceText to user language. 71 * Uses component marked as default if @a aTranslationComponent is NULL 49 72 * 50 * @returns Translated string or @a aSourceText. 51 * valid only during lifetime of the t his translator instance.73 * @returns Translated string or @a aSourceText. The returned string is 74 * valid only during lifetime of the translator instance. 52 75 */ 53 static const char *translate(const char *aContext, 76 static const char *translate(TRCOMPONENT aComponent, 77 const char *aContext, 54 78 const char *aSourceText, 55 79 const char *aComment = NULL, … … 64 88 /* Convenience function used by VirtualBox::init */ 65 89 int i_loadLanguage(const char *pszLang); 66 int i_setLanguageFile(const char *aFileName);67 com::Utf8Str i_languageFile();68 69 90 70 91 static int32_t initCritSect(); … … 76 97 uint32_t m_cInstanceRefs; 77 98 78 com::Utf8Str m_strLangFileName; 79 QMTranslator *m_pTranslator; 99 struct TranslatorComponent 100 { 101 QMTranslator *pTranslator; 102 /* Path to translation files. It includes file prefix, i.e 103 * /path/to/folder/file_prefix */ 104 com::Utf8Str strPath; 105 106 TranslatorComponent() : pTranslator(NULL) {} 107 }; 108 typedef std::list<TranslatorComponent> TranslatorList; 109 TranslatorList m_lTranslators; 110 TranslatorComponent *m_pDefaultComponent; 111 112 /* keep the language code for registration */ 113 com::Utf8Str m_strLanguage; 114 80 115 /** String cache that all translation strings are stored in. 81 116 * This is a add-only cache, which allows translate() to return C-strings w/o … … 87 122 VirtualBoxTranslator(); 88 123 89 const char *i_translate(const char *aContext, 124 int i_loadLanguageForComponent(TranslatorComponent *aComponent, const char *aLang); 125 126 int i_setLanguageFile(TranslatorComponent *aComponent, const char *aFileName); 127 128 int i_registerTranslation(const char *aTranslationPath, 129 bool aDefault, 130 TRCOMPONENT *aComponent); 131 132 int i_unregisterTranslation(TRCOMPONENT aComponent); 133 134 const char *i_translate(TRCOMPONENT aComponent, 135 const char *aContext, 90 136 const char *aSourceText, 91 137 const char *aComment = NULL, 92 138 const int aNum = -1); 93 94 139 }; 95 140 -
trunk/src/VBox/Main/include/Wrapper.h
r82968 r91312 40 40 else \ 41 41 throw setError(E_POINTER, \ 42 tr("Output argument %s points to invalid memory location (%p)"), \ 42 /* Had to define VirtualBoxBase as context switcher for translation. \ 43 * Otherwise, lupdate complains about unknown context and doesn't \ 44 * include the string into translation file */ \ 45 VirtualBoxBase::tr("Output argument %s points to invalid memory location (%p)"), \ 43 46 #arg, (void *)(arg)); \ 44 47 } while (0)
Note:
See TracChangeset
for help on using the changeset viewer.