diskdevice.cpp

00001 #include <gui/GUI.h>
00002 #include <os/OS.h>
00003 
00004 using namespace SkyGI;
00005 
00006 class MyStorageDevice : public View
00007 {
00008 public:
00009         MyStorageDevice(Window *pParent, const Rect &rFrame, unsigned int nWindowLayoutFlags);
00010 
00011         TextView *pTextView;
00012 };
00013         
00014 MyStorageDevice::MyStorageDevice(Window *pParent, const Rect &rFrame, unsigned int nWindowLayoutFlags) : View(pParent, rFrame, nWindowLayoutFlags)
00015 {
00016         int i;
00017         char str[4096];
00018 
00019         pTextView = new TextView(this, Rect(0,0,0,0), WINDOW_LAYOUT_SAME_SIZE);
00020 
00021         StorageDeviceList pList;
00022 
00023         std::vector<StorageDevice> mList = pList.Get();
00024         sprintf(str, "%d physical and partition devices", mList.size());
00025         pTextView->Append(str, true);
00026 
00027         for (i=0;i<mList.size();i++)
00028         {
00029                 pTextView->Append(mList[i].GetDevicePath(), true);
00030         }
00031         pTextView->Append("", true);
00032 
00033 
00034         mList = pList.Get(STORAGE_DEVICE_TYPE_ALL, false);
00035         sprintf(str, "%d physical devices", mList.size());
00036         pTextView->Append(str, true);
00037 
00038         for (i=0;i<mList.size();i++)
00039         {
00040                 pTextView->Append(mList[i].GetDevicePath(), true);
00041         }
00042         pTextView->Append("", true);
00043 
00044 
00045         mList = pList.Get(STORAGE_DEVICE_TYPE_ALL, true, true);
00046         sprintf(str, "%d mountable devices", mList.size());
00047         pTextView->Append(str, true);
00048 
00049         for (i=0;i<mList.size();i++)
00050         {
00051                 pTextView->Append(mList[i].GetDevicePath(), true);
00052         }
00053         pTextView->Append("", true);
00054 
00055 
00056         pTextView->Append("Detailed device view:", true);
00057         mList = pList.Get();
00058 
00059         for (i=0;i<mList.size();i++)
00060         {
00061                 pTextView->Append(String("Device : ") + mList[i].GetDevicePath(), true);
00062 
00063                 StorageDeviceType nType = mList[i].GetDeviceType();
00064                 if (nType == STORAGE_DEVICE_TYPE_FLOPPY)
00065                         pTextView->Append(String("Type   : Floppy"), true);
00066                 if (nType == STORAGE_DEVICE_TYPE_HARDDISK)
00067                         pTextView->Append(String("Type   : Harddisk"), true);
00068                 if (nType == STORAGE_DEVICE_TYPE_CD)
00069                         pTextView->Append(String("Type   : CD"), true);
00070                 if (nType == STORAGE_DEVICE_TYPE_UNKNOWN)
00071                         pTextView->Append(String("Type   : Unknown"), true);
00072 
00073                 unsigned long long ullSize = mList[i].GetSize();
00074                 sprintf(str, "Size   : %Ld (MB)", ullSize / 1024 / 1024);
00075                 pTextView->Append(str, true);
00076                                 
00077                 String szMountPoint;
00078                 if (mList[i].GetMountPoint(szMountPoint) == true)
00079                         pTextView->Append(String("Mounted: ") + szMountPoint, true);
00080                 else
00081                         pTextView->Append(String("Mounted: No"), true);
00082 
00083                 pTextView->Append(String("Read only: ") + (mList[i].IsReadOnly()?"Yes":"No"), true);
00084                 pTextView->Append(String("Has attribute support: ") + (mList[i].SupportsAttributes()?"Yes":"No"), true);
00085                 pTextView->Append(String("Has index support: ") + (mList[i].SupportsIndex()?"Yes":"No"), true);
00086                 pTextView->Append(String("Has query support: ") + (mList[i].SupportsQuery()?"Yes":"No"), true);
00087                 pTextView->Append("", true);
00088 
00089         }
00090         pTextView->Append("", true);
00091 
00092 
00093 }
00094 
00095 void StorageDeviceTest()
00096 {
00097         Rect r(Point(100, 100), Point(400, 440));
00098 
00099         ApplicationWindow* pApplicationWindow = new ApplicationWindow(r, "StorageDevice", WINDOW_LAYOUT_NOTHING, APPLICATION_WINDOW_NO_VIEW);
00100         
00101         pApplicationWindow->GetTitleWindow()->SetFlags( (TitleWindowFlags)(pApplicationWindow->GetTitleWindow()->GetFlags() ));
00102         pApplicationWindow->AttachView(new MyStorageDevice(pApplicationWindow, pApplicationWindow->GetClientRect(), WINDOW_LAYOUT_NOTHING));
00103         pApplicationWindow->Show();
00104 }
00105 

Generated on Thu Dec 13 18:13:09 2007 for SkyGI by  doxygen 1.5.1-p1