From d34f23f403e82f352e4c5d4e20966bcba2bec8c6 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Sat, 24 Aug 2019 18:25:55 +0900 Subject: tdeioslave media: clean up code related to medium mountable state in preparation for further work. Signed-off-by: Michele Calgaro --- tdeioslave/media/libmediacommon/medium.cpp | 202 +++++++++++++---------------- 1 file changed, 92 insertions(+), 110 deletions(-) (limited to 'tdeioslave/media/libmediacommon/medium.cpp') diff --git a/tdeioslave/media/libmediacommon/medium.cpp b/tdeioslave/media/libmediacommon/medium.cpp index 77e32ba0f..7ded6f0f1 100644 --- a/tdeioslave/media/libmediacommon/medium.cpp +++ b/tdeioslave/media/libmediacommon/medium.cpp @@ -23,68 +23,57 @@ const TQString Medium::SEPARATOR = "---"; +void Medium::initMedium() +{ + m_properties.clear(); + m_properties += TQString::null; // ID + m_properties += TQString::null; // UUID + m_properties += TQString::null; // NAME + m_properties += TQString::null; // LABEL + m_properties += TQString::null; // USER_LABEL + m_properties += "false"; // MOUNTABLE + m_properties += TQString::null; // DEVICE_NODE + m_properties += TQString::null; // MOUNT_POINT + m_properties += TQString::null; // FS_TYPE + m_properties += "false"; // MOUNTED + m_properties += TQString::null; // BASE_URL + m_properties += TQString::null; // MIME_TYPE + m_properties += TQString::null; // ICON_NAME + m_properties += "false"; // ENCRYPTED + m_properties += TQString::null; // CLEAR_DEVICE_UDI + m_properties += "false"; // HIDDEN + m_properties += "false"; // SOFT_HIDDEN +} + Medium::Medium(const TQString id, TQString uuid, const TQString name) { - m_properties+= id; /* ID */ - m_properties+= uuid; /* UUID */ - m_properties+= name; /* NAME */ - m_properties+= name; /* LABEL */ - m_properties+= TQString::null; /* USER_LABEL */ - - m_properties+= "false"; /* MOUNTABLE */ - m_properties+= TQString::null; /* DEVICE_NODE */ - m_properties+= TQString::null; /* MOUNT_POINT */ - m_properties+= TQString::null; /* FS_TYPE */ - m_properties+= "false"; /* MOUNTED */ - m_properties+= TQString::null; /* BASE_URL */ - m_properties+= TQString::null; /* MIME_TYPE */ - m_properties+= TQString::null; /* ICON_NAME */ - m_properties+= "false"; /* ENCRYPTED */ - m_properties+= TQString::null; /* CLEAR_DEVICE_UDI */ - m_properties+= "false"; /* HIDDEN */ - m_properties+= "false"; /* SOFT_HIDDEN */ - - loadUserLabel(); - - m_halmounted = false; + initMedium(); + if (!id.isEmpty() && !uuid.isEmpty()) + { + m_properties[ID] = id; + m_properties[UUID] = uuid; + m_properties[NAME] = name; + m_properties[LABEL] = name; + loadUserLabel(); + } } Medium::Medium() { - m_properties+= TQString::null; /* ID */ - m_properties+= TQString::null; /* UUID */ - m_properties+= TQString::null; /* NAME */ - m_properties+= TQString::null; /* LABEL */ - m_properties+= TQString::null; /* USER_LABEL */ - - m_properties+= TQString::null; /* MOUNTABLE */ - m_properties+= TQString::null; /* DEVICE_NODE */ - m_properties+= TQString::null; /* MOUNT_POINT */ - m_properties+= TQString::null; /* FS_TYPE */ - m_properties+= TQString::null; /* MOUNTED */ - m_properties+= TQString::null; /* BASE_URL */ - m_properties+= TQString::null; /* MIME_TYPE */ - m_properties+= TQString::null; /* ICON_NAME */ - m_properties+= TQString::null; /* ENCRYPTED */ - m_properties+= TQString::null; /* CLEAR_DEVICE_UDI */ - m_properties+= "false"; /* HIDDEN */ - m_properties+= "false"; /* SOFT_HIDDEN */ - - m_halmounted = false; + initMedium(); } const Medium Medium::create(const TQStringList &properties) { Medium m; - if ( properties.size() >= PROPERTIES_COUNT ) + if (properties.size() >= PROPERTIES_COUNT) { m.m_properties[ID] = properties[ID]; m.m_properties[UUID] = properties[UUID]; m.m_properties[NAME] = properties[NAME]; m.m_properties[LABEL] = properties[LABEL]; m.m_properties[USER_LABEL] = properties[USER_LABEL]; - m.m_properties[MOUNTABLE] = properties[MOUNTABLE]; m.m_properties[DEVICE_NODE] = properties[DEVICE_NODE]; m.m_properties[MOUNT_POINT] = properties[MOUNT_POINT]; @@ -106,13 +95,12 @@ Medium::MList Medium::createList(const TQStringList &properties) { MList l; - if ( properties.size() % (PROPERTIES_COUNT+1) == 0) + if (properties.size() % (PROPERTIES_COUNT+1) == 0) { - int media_count = properties.size()/(PROPERTIES_COUNT+1); - + int media_count = properties.size() / (PROPERTIES_COUNT + 1); TQStringList props = properties; - for(int i=0; i