Index: /trunk/src/VBox/Frontends/VBoxManage/VBoxManageObjectTracker.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VBoxManage/VBoxManageObjectTracker.cpp	(revision 107240)
+++ /trunk/src/VBox/Frontends/VBoxManage/VBoxManageObjectTracker.cpp	(revision 107241)
@@ -30,9 +30,8 @@
 #include <map>
 #include <vector>
+#include <iprt/time.h>
 
 using namespace com;
 using namespace std;
-
-//std::vector <com::Utf8Str> supportedIfaceList= {"IProgress", "ISession", "IMedium", "IMachine"};
 
 enum supIfaces_T
@@ -52,4 +51,48 @@
 };
 
+static void makeTimeStr(char *s, int cb, int64_t millies)
+{
+    RTTIME t;
+    RTTIMESPEC ts;
+
+    RTTimeSpecSetMilli(&ts, millies);
+
+    RTTimeExplode(&t, &ts);
+
+    RTStrPrintf(s, cb, "%04d/%02d/%02d %02d:%02d:%02d UTC",
+                        t.i32Year, t.u8Month, t.u8MonthDay,
+                        t.u8Hour, t.u8Minute, t.u8Second);
+}
+
+static Utf8Str trackedObjectStateToStr(TrackedObjectState_T aState)
+{
+    Utf8Str strState("None");
+    switch (aState)
+    {
+        case TrackedObjectState_Alive:
+            strState = "Alive";
+            break;
+        case TrackedObjectState_Deleted:
+            strState = "Deleted";
+            break;
+        case TrackedObjectState_Invalid:
+            strState = "Invalid";
+            break;
+        case TrackedObjectState_None:
+        default:
+            strState = "None";
+            break;
+    }
+
+    return strState;
+}
+
+struct TrackedObjInfo_T
+{
+    ComPtr<IUnknown> pIUnknown;
+    TrackedObjectState_T enmState;
+    LONG64 creationTime;
+    LONG64 deletionTime;
+};
 
 void printProgressObjectInfo(const ComPtr<IProgress>& pObj)
@@ -221,64 +264,112 @@
 }
 
-void printTrackedObjectInfo(supIfaces_T aIface, const map < Bstr, ComPtr<IUnknown> >& aObjMap)
+void printTrackedObjectInfo(supIfaces_T aIface, const map < Bstr, TrackedObjInfo_T >& aObjMap)
 {
     switch (aIface)
     {
         case kProgress:
-            for (const pair< const Bstr, ComPtr<IUnknown> >& item : aObjMap)
+            for (const pair< const Bstr, TrackedObjInfo_T >& item : aObjMap)
             {
                 ComPtr<IProgress> pObj;
-                item.second->QueryInterface(IID_IProgress, (void **)pObj.asOutParam());
-
-                if (pObj.isNotNull())
+                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)
                 {
-                    RTPrintf(("\nTracked object id: %s\n"), Utf8Str(item.first).c_str());
+                    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);
                 }
-            }
-
-            break;
-
-        case kSession:
-            for (const pair< const Bstr, ComPtr<IUnknown> >& item : aObjMap)
-            {
-                ComPtr<ISession> pObj;
-                item.second->QueryInterface(IID_ISession, (void **)pObj.asOutParam());
-
-                if (pObj.isNotNull())
+
+                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)
                 {
-                    RTPrintf(("\nTracked object id: %s\n"), Utf8Str(item.first).c_str());
-                    printSessionObjectInfo(pObj);
+                    makeTimeStr(szTimeValue, sizeof(szTimeValue), item.second.deletionTime);
+                    RTPrintf(("  Deletion time           %s\n"), szTimeValue);
                 }
-            }
-
-            break;
-
-        case kMedium:
-            for (const pair< const Bstr, ComPtr<IUnknown> >& item : aObjMap)
-            {
-                ComPtr<IMedium> pObj;
-                item.second->QueryInterface(IID_IMedium, (void **)pObj.asOutParam());
-
-                if (pObj.isNotNull())
+
+                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)
                 {
-                    RTPrintf(("\nTracked object id: %s\n"), Utf8Str(item.first).c_str());
-                    printMediumObjectInfo(pObj);
+                    makeTimeStr(szTimeValue, sizeof(szTimeValue), item.second.deletionTime);
+                    RTPrintf(("  Deletion time           %s\n"), szTimeValue);
                 }
-            }
-
-            break;
-
-        case kMachine:
-            for (const pair< const Bstr, ComPtr<IUnknown> >& item : aObjMap)
-            {
-                ComPtr<IMachine> pObj;
-                item.second->QueryInterface(IID_IMachine, (void **)pObj.asOutParam());
-
-                if (pObj.isNotNull())
-                {
-                    RTPrintf(("\nTracked object id: %s\n"), Utf8Str(item.first).c_str());
+
+                if (item.second.enmState != TrackedObjectState_Invalid && pObj.isNotNull())
                     printMachineObjectInfo(pObj);
-                }
             }
 
@@ -364,5 +455,6 @@
         if (SUCCEEDED(hrc))
         {
-            map < Bstr, ComPtr<IUnknown> > lObjMap;
+            map < Bstr, TrackedObjInfo_T > lObjInfoMap;
+
             if (strObjUuid.isNotEmpty())
             {
@@ -372,7 +464,11 @@
                     if (bstrObjId.equals(strObjUuid.c_str()))
                     {
-                        ComPtr<IUnknown> pIUnknown;
-                        hrc = pVirtualBox->GetTrackedObject(bstrObjId.raw(), pIUnknown.asOutParam());
-                        lObjMap[bstrObjId] = pIUnknown;
+                        TrackedObjInfo_T objInfo;
+                        hrc = pVirtualBox->GetTrackedObject(bstrObjId.raw(),
+                                                            objInfo.pIUnknown.asOutParam(),
+                                                            &objInfo.enmState,
+                                                            &objInfo.creationTime,
+                                                            &objInfo.deletionTime);
+                        lObjInfoMap[bstrObjId] = objInfo;
                         break;
                     }
@@ -384,15 +480,24 @@
                 {
                     Bstr bstrObjId = ObjIDsList[i];
-                    ComPtr<IUnknown> pIUnknown;
-                    hrc = pVirtualBox->GetTrackedObject(bstrObjId.raw(), pIUnknown.asOutParam());
-                    lObjMap[bstrObjId] = pIUnknown;
+                    TrackedObjInfo_T objInfo;
+                    hrc = pVirtualBox->GetTrackedObject(bstrObjId.raw(),
+                                                        objInfo.pIUnknown.asOutParam(),
+                                                        &objInfo.enmState,
+                                                        &objInfo.creationTime,
+                                                        &objInfo.deletionTime);
+                    if (SUCCEEDED(hrc))
+                        lObjInfoMap[bstrObjId] = objInfo;
+                    else
+                        RTPrintf(("VirtualBox::getTrackedObject() returned the error 0x%LX\n"), hrc);
                 }
             }
 
-            if (!lObjMap.empty())
-                printTrackedObjectInfo(foundIface, lObjMap);
+            if (!lObjInfoMap.empty())
+                printTrackedObjectInfo(foundIface, lObjInfoMap);
             else
-                RTPrintf(("Object with Id %s wasn't found or has \"invalid\" state\n"), strObjUuid.c_str());
+                RTPrintf(("Object with Id %s wasn't found\n"), strObjUuid.c_str());
         }
+        else
+            RTPrintf(("VirtualBox::getTrackedObjectIds() returned the error 0x%LX\n"), hrc);
     }
     else
