Changeset 45271 in vbox
- Timestamp:
- Apr 1, 2013 12:03:35 PM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 84661
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/globals
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp
r45270 r45271 386 386 } 387 387 388 void UIMessageCenter::cannotFindMachineByName(const CVirtualBox &vbox, const QString & name)388 void UIMessageCenter::cannotFindMachineByName(const CVirtualBox &vbox, const QString &strName) 389 389 { 390 390 message(0, MessageType_Error, 391 tr("There is no virtual machine named <b>%1</b>.").arg(name), 391 tr("There is no virtual machine named <b>%1</b>.").arg(strName), 392 formatErrorInfo(vbox)); 393 } 394 395 void UIMessageCenter::cannotFindMachineById(const CVirtualBox &vbox, const QString &strId) 396 { 397 message(0, MessageType_Error, 398 tr("There is no virtual machine with id <b>%1</b>.").arg(strId), 392 399 formatErrorInfo(vbox)); 393 400 } -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h
r45270 r45271 202 202 void cannotLoadGlobalConfig(const CVirtualBox &vbox, const QString &strError); 203 203 void cannotSaveGlobalConfig(const CVirtualBox &vbox); 204 void cannotFindMachineByName(const CVirtualBox &vbox, const QString &name); 204 void cannotFindMachineByName(const CVirtualBox &vbox, const QString &strName); 205 void cannotFindMachineById(const CVirtualBox &vbox, const QString &strId); 205 206 void cannotOpenSession(const CSession &session); 206 207 void cannotOpenSession(const CVirtualBox &vbox, const CMachine &machine, const CProgress &progress = CProgress()); -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp
r45269 r45271 1725 1725 } 1726 1726 1727 /** 1728 * Opens a direct session for a machine with the given ID. 1729 * This method does user-friendly error handling (display error messages, etc.). 1730 * and returns a null CSession object in case of any error. 1731 * If this method succeeds, don't forget to close the returned session when 1732 * it is no more necessary. 1733 * 1734 * @param aId Machine ID. 1735 * @param aLockType @c KLockType_Shared to open an existing session with 1736 * the machine which is already running, @c KLockType_Write 1737 * to open a new direct session, @c KLockType_VM to open 1738 * a new session for running a VM in this process. 1739 */ 1740 CSession VBoxGlobal::openSession(const QString &aId, KLockType aLockType /* = KLockType_Shared */) 1741 { 1727 CSession VBoxGlobal::openSession(const QString &strId, KLockType lockType /* = KLockType_Shared */) 1728 { 1729 /* Create empty session instance: */ 1742 1730 CSession session; 1743 1731 session.createInstance(CLSID_Session); 1744 1732 if (session.isNull()) 1745 1733 { 1746 msgCenter().cannotOpenSession 1734 msgCenter().cannotOpenSession(session); 1747 1735 return session; 1748 1736 } 1749 1737 1750 CMachine foundMachine = CVirtualBox(mVBox).FindMachine(aId); 1751 if (!foundMachine.isNull()) 1752 { 1753 foundMachine.LockMachine(session, aLockType); 1754 if (session.GetType() == KSessionType_Shared) 1755 { 1756 CMachine machine = session.GetMachine(); 1757 /* Make sure that the language is in two letter code. 1758 * Note: if languageId() returns an empty string lang.name() will 1759 * return "C" which is an valid language code. */ 1760 QLocale lang(VBoxGlobal::languageId()); 1761 machine.SetGuestPropertyValue ("/VirtualBox/HostInfo/GUI/LanguageID", lang.name()); 1762 } 1763 } 1764 1765 if (!foundMachine.isOk()) 1766 { 1767 msgCenter().cannotOpenSession(foundMachine); 1738 /* Search for the corresponding machine: */ 1739 CMachine machine = mVBox.FindMachine(strId); 1740 if (machine.isNull()) 1741 { 1742 msgCenter().cannotFindMachineById(mVBox, strId); 1743 return session; 1744 } 1745 1746 /* Lock found machine to session: */ 1747 machine.LockMachine(session, lockType); 1748 1749 /* Pass the language ID as the property to the guest: */ 1750 if (session.GetType() == KSessionType_Shared) 1751 { 1752 CMachine startedMachine = session.GetMachine(); 1753 /* Make sure that the language is in two letter code. 1754 * Note: if languageId() returns an empty string lang.name() will 1755 * return "C" which is an valid language code. */ 1756 QLocale lang(VBoxGlobal::languageId()); 1757 startedMachine.SetGuestPropertyValue("/VirtualBox/HostInfo/GUI/LanguageID", lang.name()); 1758 } 1759 1760 /* Show locking errors if any: */ 1761 if (!machine.isOk()) 1762 { 1763 msgCenter().cannotOpenSession(machine); 1768 1764 session.detach(); 1769 1765 } 1770 1766 else if (!mVBox.isOk()) 1771 1767 { 1772 msgCenter().cannotOpenSession(mVBox, foundMachine);1768 msgCenter().cannotOpenSession(mVBox, machine); 1773 1769 session.detach(); 1774 1770 } 1775 1771 1772 /* Return resulting session: */ 1776 1773 return session; 1777 1774 }
Note:
See TracChangeset
for help on using the changeset viewer.