Index: /trunk/src/VBox/Frontends/VBoxManage/VBoxManageObjectTracker.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VBoxManage/VBoxManageObjectTracker.cpp	(revision 107260)
+++ /trunk/src/VBox/Frontends/VBoxManage/VBoxManageObjectTracker.cpp	(revision 107261)
@@ -51,4 +51,9 @@
 };
 
+static void printProgressObjectInfo(const ComPtr<IProgress>& pObj);
+static void printSessionObjectInfo(const ComPtr<ISession>& pObj);
+static void printMediumObjectInfo(const ComPtr<IMedium>& pObj);
+static void printMachineObjectInfo(const ComPtr<IMachine>& pObj);
+
 static void makeTimeStr(char *s, int cb, int64_t millies)
 {
@@ -96,5 +101,100 @@
 };
 
-void printProgressObjectInfo(const ComPtr<IProgress>& pObj)
+struct TrackedObjInfoShow
+{
+    supIfaces_T m_iface;
+    Utf8Str m_id;
+    TrackedObjInfo_T m_objInfo;
+
+    TrackedObjInfoShow(Utf8Str aId, const TrackedObjInfo_T& aObjInfo, supIfaces_T aIface):
+        m_iface(aIface),
+        m_id(aId)
+    {
+        m_objInfo = aObjInfo;
+    }
+
+    TrackedObjInfoShow(supIfaces_T aIface): m_iface(aIface) {}
+
+    void setObjId(const Utf8Str& aId)
+    {
+        m_id = aId;
+    }
+
+    void setObjInfo(const TrackedObjInfo_T& aObjInfo)
+    {
+        m_objInfo = aObjInfo;
+    }
+
+    void show() const
+    {
+        RTPrintf(("\nTracked object id: %s\n"), m_id.c_str());
+
+        Utf8Str strState = trackedObjectStateToStr(m_objInfo.enmState);
+        RTPrintf(("  State                   %s\n"), strState.c_str());
+
+        char szTimeValue[128];
+        makeTimeStr(szTimeValue, sizeof(szTimeValue), m_objInfo.creationTime);
+        RTPrintf(("  Creation time           %s\n"), szTimeValue);
+
+        if (m_objInfo.deletionTime != 0)
+        {
+            makeTimeStr(szTimeValue, sizeof(szTimeValue), m_objInfo.deletionTime);
+            RTPrintf(("  Deletion time           %s\n"), szTimeValue);
+        }
+
+        switch (m_iface)
+        {
+            case kProgress:
+            {
+                if (m_objInfo.enmState != TrackedObjectState_Invalid)
+                {
+                    ComPtr<IProgress> pObj;
+                    m_objInfo.pIUnknown->QueryInterface(IID_IProgress, (void **)pObj.asOutParam());
+                    if (pObj.isNotNull())
+                        printProgressObjectInfo(pObj);
+                }
+                break;
+            }
+            case kSession:
+            {
+                if (m_objInfo.enmState != TrackedObjectState_Invalid)
+                {
+                    ComPtr<ISession> pObj;
+                    m_objInfo.pIUnknown->QueryInterface(IID_ISession, (void **)pObj.asOutParam());
+                    if (pObj.isNotNull())
+                        printSessionObjectInfo(pObj);
+                }
+                break;
+            }
+            case kMedium:
+            {
+                if (m_objInfo.enmState != TrackedObjectState_Invalid)
+                {
+                    ComPtr<IMedium> pObj;
+                    m_objInfo.pIUnknown->QueryInterface(IID_IMedium, (void **)pObj.asOutParam());
+                    if (pObj.isNotNull())
+                        printMediumObjectInfo(pObj);
+                }
+                break;
+            }
+            case kMachine:
+            {
+                if (m_objInfo.enmState != TrackedObjectState_Invalid)
+                {
+                    ComPtr<IMachine> pObj;
+                    m_objInfo.pIUnknown->QueryInterface(IID_IMachine, (void **)pObj.asOutParam());
+                    if(pObj.isNotNull())
+                        printMachineObjectInfo(pObj);
+                }
+                break;
+            }
+            /* Impossible situation but to support the default case */
+            default:
+                RTPrintf("Interface isn't supported by object tracker at moment");
+        }
+    }
+};
+
+static void printProgressObjectInfo(const ComPtr<IProgress>& pObj)
 {
     if (pObj.isNotNull())
@@ -117,5 +217,5 @@
 }
 
-void printSessionObjectInfo(const ComPtr<ISession>& pObj)
+static void printSessionObjectInfo(const ComPtr<ISession>& pObj)
 {
     if (pObj.isNotNull())
@@ -136,5 +236,5 @@
 }
 
-void printMediumObjectInfo(const ComPtr<IMedium>& pObj)
+static void printMediumObjectInfo(const ComPtr<IMedium>& pObj)
 {
     if (pObj.isNotNull())
@@ -206,5 +306,5 @@
 }
 
-void printMachineObjectInfo(const ComPtr<IMachine>& pObj)
+static void printMachineObjectInfo(const ComPtr<IMachine>& pObj)
 {
     if (pObj.isNotNull())
@@ -240,7 +340,4 @@
         pObj->COMGETTER(SettingsFilePath)(bStrAttr.asOutParam());
         RTPrintf(("  SettingsFilePath        %s\n"), Utf8Str(bStrAttr).c_str());
-
-        pObj->COMGETTER(SettingsAuxFilePath)(bStrAttr.asOutParam());
-        RTPrintf(("  SettingsAuxFilePath     %s\n"), Utf8Str(bStrAttr).c_str());
 
         pObj->COMGETTER(StateFilePath)(bStrAttr.asOutParam());
@@ -266,118 +363,12 @@
 void printTrackedObjectInfo(supIfaces_T aIface, const map < Bstr, TrackedObjInfo_T >& aObjMap)
 {
-    switch (aIface)
-    {
-        case kProgress:
-            for (const pair< const Bstr, TrackedObjInfo_T >& item : aObjMap)
-            {
-                ComPtr<IProgress> pObj;
-                item.second.pIUnknown->QueryInterface(IID_IProgress, (void **)pObj.asOutParam());
-
-                RTPrintf(("\nTracked object id: %s\n"), Utf8Str(item.first).c_str());
-
-                Utf8Str strState = trackedObjectStateToStr(item.second.enmState);
-                RTPrintf(("  State                   %s\n"), strState.c_str());
-
-                char szTimeValue[128];
-                makeTimeStr(szTimeValue, sizeof(szTimeValue), item.second.creationTime);
-                RTPrintf(("  Creation time           %s\n"), szTimeValue);
-
-                if (item.second.deletionTime != 0)
-                {
-                    makeTimeStr(szTimeValue, sizeof(szTimeValue), item.second.deletionTime);
-                    RTPrintf(("  Deletion time           %s\n"), szTimeValue);
-                }
-
-                if (item.second.enmState != TrackedObjectState_Invalid && pObj.isNotNull())
-                    printProgressObjectInfo(pObj);
-            }
-
-            break;
-
-        case kSession:
-            for (const pair< const Bstr, TrackedObjInfo_T >& item : aObjMap)
-            {
-                ComPtr<ISession> pObj;
-                item.second.pIUnknown->QueryInterface(IID_ISession, (void **)pObj.asOutParam());
-
-                RTPrintf(("\nTracked object id: %s\n"), Utf8Str(item.first).c_str());
-
-                Utf8Str strState = trackedObjectStateToStr(item.second.enmState);
-                RTPrintf(("  State                   %s\n"), strState.c_str());
-
-                char szTimeValue[128];
-                makeTimeStr(szTimeValue, sizeof(szTimeValue), item.second.creationTime);
-                RTPrintf(("  Creation time           %s\n"), szTimeValue);
-
-                if (item.second.deletionTime != 0)
-                {
-                    makeTimeStr(szTimeValue, sizeof(szTimeValue), item.second.deletionTime);
-                    RTPrintf(("  Deletion time           %s\n"), szTimeValue);
-                }
-
-                if (item.second.enmState != TrackedObjectState_Invalid && pObj.isNotNull())
-                    printSessionObjectInfo(pObj);
-            }
-
-            break;
-
-        case kMedium:
-            for (const pair< const Bstr, TrackedObjInfo_T >& item : aObjMap)
-            {
-                ComPtr<IMedium> pObj;
-                item.second.pIUnknown->QueryInterface(IID_IMedium, (void **)pObj.asOutParam());
-
-                RTPrintf(("\nTracked object id: %s\n"), Utf8Str(item.first).c_str());
-
-                Utf8Str strState = trackedObjectStateToStr(item.second.enmState);
-                RTPrintf(("  State                   %s\n"), strState.c_str());
-
-                char szTimeValue[128];
-                makeTimeStr(szTimeValue, sizeof(szTimeValue), item.second.creationTime);
-                RTPrintf(("  Creation time           %s\n"), szTimeValue);
-
-                if (item.second.deletionTime != 0)
-                {
-                    makeTimeStr(szTimeValue, sizeof(szTimeValue), item.second.deletionTime);
-                    RTPrintf(("  Deletion time           %s\n"), szTimeValue);
-                }
-
-                if (item.second.enmState != TrackedObjectState_Invalid && pObj.isNotNull())
-                    printMediumObjectInfo(pObj);
-            }
-
-            break;
-
-        case kMachine:
-            for (const pair< const Bstr, TrackedObjInfo_T >& item : aObjMap)
-            {
-                ComPtr<IMachine> pObj;
-                item.second.pIUnknown->QueryInterface(IID_IMachine, (void **)pObj.asOutParam());
-
-                RTPrintf(("\nTracked object id: %s\n"), Utf8Str(item.first).c_str());
-
-                Utf8Str strState = trackedObjectStateToStr(item.second.enmState);
-                RTPrintf(("  State                   %s\n"), strState.c_str());
-
-                char szTimeValue[128];
-                makeTimeStr(szTimeValue, sizeof(szTimeValue), item.second.creationTime);
-                RTPrintf(("  Creation time           %s\n"), szTimeValue);
-
-                if (item.second.deletionTime != 0)
-                {
-                    makeTimeStr(szTimeValue, sizeof(szTimeValue), item.second.deletionTime);
-                    RTPrintf(("  Deletion time           %s\n"), szTimeValue);
-                }
-
-                if (item.second.enmState != TrackedObjectState_Invalid && pObj.isNotNull())
-                    printMachineObjectInfo(pObj);
-            }
-
-            break;
-
-        default:
-            RTPrintf("Interface isn't supported by object tracker at moment");
-            break;
-    }
+    TrackedObjInfoShow trackedObjInfoShow(aIface);
+    for (const pair< const Bstr, TrackedObjInfo_T >& item : aObjMap)
+    {
+        trackedObjInfoShow.setObjId(Utf8Str(item.first));
+        trackedObjInfoShow.setObjInfo(item.second);
+        trackedObjInfoShow.show();
+    }
+
 }
 
