- Timestamp:
- Dec 15, 2021 3:47:00 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManage.cpp
r92937 r92938 562 562 #endif 563 563 564 #ifdef VBOX_WITH_VBOXMANAGE_NLS 565 /* 566 * Initialize the translator and associated fun. 567 */ 568 util::InitAutoLockSystem(); 569 ComObjPtr<VBoxEventListenerImpl> ptrEventListner; 570 PTRCOMPONENT pTrComponent = NULL; 571 VirtualBoxTranslator *pTranslator = VirtualBoxTranslator::instance(); 572 if (pTranslator != NULL) 573 { 574 char szNlsPath[RTPATH_MAX]; 575 vrc = RTPathAppPrivateNoArch(szNlsPath, sizeof(szNlsPath)); 576 if (RT_SUCCESS(vrc)) 577 vrc = RTPathAppend(szNlsPath, sizeof(szNlsPath), "nls" RTPATH_SLASH_STR "VBoxManageNls"); 578 if (RT_SUCCESS(vrc)) 579 { 580 vrc = pTranslator->registerTranslation(szNlsPath, true, &pTrComponent); 581 if (RT_SUCCESS(vrc)) 582 { 583 vrc = pTranslator->i_loadLanguage(NULL); 584 if (RT_SUCCESS(vrc)) 585 { 586 com::Utf8Str strLang = pTranslator->language(); 587 setBuiltInHelpLanguage(strLang.c_str()); 588 } 589 else 590 RTMsgWarning("Load language failed: %Rrc\n", vrc); 591 } 592 else 593 RTMsgWarning("Register translation failed: %Rrc\n", vrc); 594 } 595 else 596 RTMsgWarning("Path constructing failed: %Rrc\n", vrc); 597 } 598 #endif 599 564 600 /* 565 601 * Parse the global options … … 576 612 char **papszNewArgv = NULL; 577 613 #endif 578 579 #ifdef VBOX_WITH_VBOXMANAGE_NLS580 ComPtr<IEventListener> pEventListener;581 PTRCOMPONENT pTrComponent = NULL;582 util::InitAutoLockSystem();583 VirtualBoxTranslator *pTranslator = VirtualBoxTranslator::instance();584 if (pTranslator != NULL)585 {586 char szNlsPath[RTPATH_MAX];587 vrc = RTPathAppPrivateNoArch(szNlsPath, sizeof(szNlsPath));588 if (RT_SUCCESS(vrc))589 vrc = RTPathAppend(szNlsPath, sizeof(szNlsPath), "nls" RTPATH_SLASH_STR "VBoxManageNls");590 if (RT_SUCCESS(vrc))591 {592 vrc = pTranslator->registerTranslation(szNlsPath, true, &pTrComponent);593 if (RT_SUCCESS(vrc))594 {595 vrc = pTranslator->i_loadLanguage(NULL);596 if (RT_SUCCESS(vrc))597 {598 com::Utf8Str strLang = pTranslator->language();599 setBuiltInHelpLanguage(strLang.c_str());600 }601 else602 LogRelFunc(("Load language failed: %Rrc\n", vrc));603 }604 else605 LogRelFunc(("Register translation failed: %Rrc\n", vrc));606 }607 else608 LogRelFunc(("Path constructing failed: %Rrc\n", vrc));609 610 }611 #endif612 613 614 for (int i = 1; i < argc || argc <= iCmd; i++) 614 615 { … … 812 813 { 813 814 #ifdef VBOX_WITH_VBOXMANAGE_NLS 815 /* Load language settings from IVirtualBox. */ 814 816 if (pTranslator != NULL) 815 817 { … … 821 823 } 822 824 else 823 { 824 /* Just log and ignore the language error */ 825 LogRel(("Failed to load API language, %Rhrc", hrc1)); 826 } 825 RTMsgWarning("Failed to load API language: %Rhrc", hrc1); 826 827 827 /* VirtualBox language events registration. */ 828 828 ComPtr<IEventSource> pES; … … 830 830 if (SUCCEEDED(hrc1)) 831 831 { 832 ComObjPtr<VBoxEventListenerImpl> listener; 833 listener.createObject(); 834 listener->init(new VBoxEventListener()); 835 pEventListener = listener; 836 com::SafeArray<VBoxEventType_T> eventTypes; 837 eventTypes.push_back(VBoxEventType_OnLanguageChanged); 838 hrc1 = pES->RegisterListener(pEventListener, ComSafeArrayAsInParam(eventTypes), true); 832 hrc1 = ptrEventListner.createObject(); 833 if (SUCCEEDED(hrc1)) 834 hrc1 = ptrEventListner->init(new VBoxEventListener()); 835 if (SUCCEEDED(hrc1)) 836 { 837 com::SafeArray<VBoxEventType_T> eventTypes; 838 eventTypes.push_back(VBoxEventType_OnLanguageChanged); 839 hrc1 = pES->RegisterListener(ptrEventListner, ComSafeArrayAsInParam(eventTypes), true); 840 } 839 841 if (FAILED(hrc1)) 840 842 { 841 p EventListener.setNull();842 LogRel(("Failed to register event listener, %Rhrc", hrc1));843 ptrEventListner.setNull(); 844 RTMsgWarning("Failed to register event listener: %Rhrc", hrc1); 843 845 } 844 846 } … … 900 902 #ifdef VBOX_WITH_VBOXMANAGE_NLS 901 903 /* VirtualBox event callback unregistration. */ 902 if (p EventListener.isNotNull())904 if (ptrEventListner.isNotNull()) 903 905 { 904 906 ComPtr<IEventSource> pES; … … 906 908 if (pES.isNotNull()) 907 909 { 908 hrc1 = pES->UnregisterListener(p EventListener);910 hrc1 = pES->UnregisterListener(ptrEventListner); 909 911 if (FAILED(hrc1)) 910 912 LogRel(("Failed to unregister listener, %Rhrc", hrc1)); 911 913 } 912 p EventListener.setNull();914 ptrEventListner.setNull(); 913 915 } 914 916 #endif
Note:
See TracChangeset
for help on using the changeset viewer.