kscd: Fix device detection from Media Manager

Commit d36f6096 in tdebase has changed the order of
items in the device properties returned by Media Manager.
The indexes of items used in kscd must be consistent
with tdebase.
This resolves Bug 2834

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
pull/1/head
Slávek Banko 6 years ago
parent 81449b86f6
commit 63f0675169

@ -119,16 +119,21 @@ void configWidget::getMediaDevices()
TQStringList::const_iterator it = list.begin(); TQStringList::const_iterator it = list.begin();
TQStringList::const_iterator itEnd = list.end(); TQStringList::const_iterator itEnd = list.end();
// it would be much better if libmediacommon was in tdelibs // it would be much better if libmediacommon was in tdelibs
// see tdebase/tdeioslave/media/libmediacommon/medium.h
while (it != itEnd) { while (it != itEnd) {
it++; TQString url;
if (it == itEnd) break; for ( int i = 0; i<12 && it != itEnd; i++, ++it ) {
TQString url="media:/"+(*it); // is it always right? ervin? if (i == 2) { // NAME
kdDebug() << "checking " << url << endl; url = "media:/"+(*it);
for (int i=0;i<9;i++) ++it; // go to mimetype (MIME_TYPE-NAME from medium.h) kdDebug() << "checking " << url << endl;
kdDebug() << "Mime: " << *it << endl; }
if (it!=itEnd && (*it)=="media/audiocd") { if (i == 11) { // MIME_TYPE
kcfg_cdDevice->comboBox()->insertItem(url); kdDebug() << "Mime: " << *it << endl;
} if ((*it)=="media/audiocd") {
kcfg_cdDevice->comboBox()->insertItem(url);
}
}
}
while (it !=itEnd && (*it)!="---") ++it; // go to end of current device's properties while (it !=itEnd && (*it)!="---") ++it; // go to end of current device's properties
++it; ++it;
} }

@ -241,15 +241,14 @@ TQString TDECompactDisc::urlToDevice(const TQString& device)
DCOPRef mediamanager("kded", "mediamanager"); DCOPRef mediamanager("kded", "mediamanager");
DCOPReply reply = mediamanager.call("properties(TQString)", deviceUrl.fileName()); DCOPReply reply = mediamanager.call("properties(TQString)", deviceUrl.fileName());
TQStringList properties = reply; TQStringList properties = reply;
if (!reply.isValid() || properties.count() < 6) if (!reply.isValid() || properties.count() < 7 ) {
{
kdError() << "Invalid reply from mediamanager" << endl; kdError() << "Invalid reply from mediamanager" << endl;
return defaultDevice; return defaultDevice;
} }
else else {
{ /* see DEVICE_NODE in tdebase/tdeioslave/media/libmediacommon/medium.h */
kdDebug() << "Reply from mediamanager " << properties[5] << endl; kdDebug() << "Reply from mediamanager " << properties[6] << endl;
return properties[5]; return properties[6];
} }
} }

Loading…
Cancel
Save