[Digikam-devel] extragear/graphics/digikam/utilities/cameragui

Gilles Caulier caulier.gilles at gmail.com
Wed Sep 5 20:55:10 BST 2007


SVN commit 708838 by cgilles:

digiKam from trunk (KDE4) : Camera GUI : Give storage media free-space and capacity with Gphoto2 camera.

This require libgphoto2 2.4.0 to compile.

Tested fine with my Minolta Dynax 5D in PTP mode
Test fail with my Olympus C3000Z (pure GPhoto2 drivers) because this camera do not support this feature.

I need more feedback from users if you use Gphoto2 drivers (all Canon cameras for ex.). Thanks in advance...

Note: digiKam for KDE4 need mandatory libgphoto2 2.4.0 to compile. There is no way to get libgphoto2 major/minor/patch revision during compilation.
      digiKam for KDE3 implementation still compatible with all libgphoto2 release because it don't provide this new function in Camera Gui.

CCMAIL: digikam-devel at kde.org



 M  +118 -5    gpcamera.cpp  


--- trunk/extragear/graphics/digikam/utilities/cameragui/gpcamera.cpp #708837:708838
@@ -155,11 +155,6 @@
     return d->globalPath;   
 }
 
-bool GPCamera::getFreeSpace(unsigned long& kBSize, unsigned long& kBAvail)
-{
-    return false; // TODO : not yet implemented.
-}
-
 bool GPCamera::thumbnailSupport()
 {
     return d->thumbnailSupport;    
@@ -306,6 +301,124 @@
     m_status->cancel = true;
 }
 
+/* This method depand of libgphoto2 2.4.0 */
+bool GPCamera::getFreeSpace(unsigned long& kBSize, unsigned long& kBAvail)
+{
+    int                       nrofsinfos;
+    CameraStorageInformation *sinfos;
+
+    if (m_status) 
+    {
+        delete m_status;
+        m_status = 0;
+    }
+    m_status = new GPStatus();
+
+    int errorCode = gp_camera_get_storageinfo (d->camera, &sinfos, &nrofsinfos, m_status->context);
+    if (errorCode != GP_OK) 
+    {
+        DDebug() << "Getting storage information not supported for this camera!" << endl;
+        printGphotoErrorDescription(errorCode);
+        delete m_status;
+        m_status = 0;
+        return false;
+    }
+
+    for (int i = 0 ; i < nrofsinfos ; i++) 
+    {
+        if (sinfos[i].fields & GP_STORAGEINFO_FILESYSTEMTYPE) 
+        {
+            switch (sinfos[i].fstype) 
+            {
+                case GP_STORAGEINFO_FST_DCF:       // Camera layout (DCIM)
+                {
+                    if (sinfos[i].fields & GP_STORAGEINFO_LABEL)
+                        DDebug() << "Storage label: " << QString(sinfos[i].label) << endl;
+                    if (sinfos[i].fields & GP_STORAGEINFO_DESCRIPTION)
+                        DDebug() << "Storage description: " << QString(sinfos[i].description) << endl;
+                    if (sinfos[i].fields & GP_STORAGEINFO_BASE)
+                        DDebug() << "Storage base-dir: " << QString(sinfos[i].basedir) << endl;
+            
+                    if (sinfos[i].fields & GP_STORAGEINFO_ACCESS) 
+                    {
+                        switch (sinfos[i].access) 
+                        {
+                            case GP_STORAGEINFO_AC_READWRITE:
+                                DDebug() << "Storage access: R/W" << endl;
+                                break;
+                            case GP_STORAGEINFO_AC_READONLY:
+                                DDebug() << "Storage access: RO" << endl;
+                                break;
+                            case GP_STORAGEINFO_AC_READONLY_WITH_DELETE:
+                                DDebug() << "Storage access: RO + Del" << endl;
+                                break;
+                            default:
+                                break;
+                        }
+                    }
+            
+                    if (sinfos[i].fields & GP_STORAGEINFO_STORAGETYPE) 
+                    {
+                        switch (sinfos[i].type) 
+                        {
+                            case GP_STORAGEINFO_ST_FIXED_ROM:
+                                DDebug() << "Storage type: fixed ROM" << endl;
+                                break;
+                            case GP_STORAGEINFO_ST_REMOVABLE_ROM:
+                                DDebug() << "Storage type: removable ROM" << endl;
+                                break;
+                            case GP_STORAGEINFO_ST_FIXED_RAM:
+                                DDebug() << "Storage type: fixed RAM" << endl;
+                                break;
+                            case GP_STORAGEINFO_ST_REMOVABLE_RAM:
+                                DDebug() << "Storage type: removable RAM" << endl;
+                                break;
+                            case GP_STORAGEINFO_ST_UNKNOWN:
+                            default:
+                                DDebug() << "Storage type: unknow" << endl;
+                                break;
+                        }
+                    }
+
+                    if (sinfos[i].fields & GP_STORAGEINFO_MAXCAPACITY)
+                    {
+                        kBSize = sinfos[i].capacitykbytes;
+                        DDebug() << "Storage capacity: " << kBSize << endl;
+                    }
+                    else
+                    {
+                        delete m_status;
+                        m_status = 0;
+                        return false;
+                    }
+            
+                    if (sinfos[i].fields & GP_STORAGEINFO_FREESPACEKBYTES)
+                    {
+                        kBAvail = sinfos[i].freekbytes;
+                        DDebug() << "Storage free-space: " << kBAvail << endl;
+                    }
+                    else
+                    {
+                        delete m_status;
+                        m_status = 0;
+                        return false;
+                    }
+                    break;
+                }
+                case GP_STORAGEINFO_FST_UNDEFINED:
+                case GP_STORAGEINFO_FST_GENERICFLAT:
+                case GP_STORAGEINFO_FST_GENERICHIERARCHICAL:
+                default:
+                    break;
+            }
+        }
+    }
+
+    delete m_status;
+    m_status = 0;
+    return true;
+}
+
 void GPCamera::getAllFolders(const QString& rootFolder,
                              QStringList& folderList)
 {



More information about the Digikam-devel mailing list