summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-12-20 21:20:26 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-12-20 21:20:26 (GMT)
commitc288ff3566fd2fdbed95ddda3335be0fd4b8de9c (patch)
tree55373d6ca3e806f0ae133abe9f904653c6e4abcc
parent987a683ff51997cb23cb931af99c6554651742d7 (diff)
parentd6a7931c5a2b90c0c276a1367135c9dc4e7532cd (diff)
downloadQt-c288ff3566fd2fdbed95ddda3335be0fd4b8de9c.zip
Qt-c288ff3566fd2fdbed95ddda3335be0fd4b8de9c.tar.gz
Qt-c288ff3566fd2fdbed95ddda3335be0fd4b8de9c.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-s60-public into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-s60-public: runonphone: Only print the modprobe instructions on linux reword: Make the USB serial device enumeration work on OS X, too runonphone: Check that the device->config is valid before dereferencing it Remove few compile warnings Fix using QFileDialog statics in Symbian.
-rw-r--r--src/gui/dialogs/qfiledialog_symbian.cpp73
-rw-r--r--tools/runonphone/serenum_unix.cpp29
2 files changed, 67 insertions, 35 deletions
diff --git a/src/gui/dialogs/qfiledialog_symbian.cpp b/src/gui/dialogs/qfiledialog_symbian.cpp
index 1f70305..1fc5f5e 100644
--- a/src/gui/dialogs/qfiledialog_symbian.cpp
+++ b/src/gui/dialogs/qfiledialog_symbian.cpp
@@ -64,7 +64,7 @@ public:
filterList.clear();
if (filter.left(2) == QLatin1String("*.")) {
//Filter has only extensions
- filterList << filter.split(" ");
+ filterList << filter.split(QLatin1String(" "));
return;
} else {
//Extensions are in parenthesis and there may be several filters
@@ -75,7 +75,7 @@ public:
return;
}
}
- QRegExp rx("\\(([^\\)]*)\\)");
+ QRegExp rx(QLatin1String("\\(([^\\)]*)\\)"));
int pos = 0;
while ((pos = rx.indexIn(filter, pos)) != -1) {
filterList << rx.cap(1).split(QLatin1String(" "));
@@ -119,36 +119,49 @@ static QString launchSymbianDialog(const QString dialogCaption, const QString st
{
QString selection;
#if defined(Q_WS_S60) && defined(SYMBIAN_VERSION_SYMBIAN3)
- QT_TRAP_THROWING(
- TFileName startFolder;
- if (!startDirectory.isEmpty()) {
- QString dir = QDir::toNativeSeparators(startDirectory);
+ TFileName startFolder;
+ if (!startDirectory.isEmpty()) {
+ QString dir = QDir::toNativeSeparators(QFileDialogPrivate::workingDirectory(startDirectory));
+ startFolder = qt_QString2TPtrC(dir);
+ }
+ TInt types = AknCommonDialogsDynMem::EMemoryTypeMMCExternal|
+ AknCommonDialogsDynMem::EMemoryTypeInternalMassStorage|
+ AknCommonDialogsDynMem::EMemoryTypePhone;
+
+ TPtrC titlePtr(qt_QString2TPtrC(dialogCaption));
+ TFileName target;
+ bool select = false;
+ int tryCount = 2;
+ while (tryCount--) {
+ TInt err(KErrNone);
+ TRAP(err,
+ if (dialogMode == DialogOpen) {
+ CExtensionFilter* extensionFilter = new (ELeave) CExtensionFilter;
+ CleanupStack::PushL(extensionFilter);
+ extensionFilter->setFilter(filter);
+ select = AknCommonDialogsDynMem::RunSelectDlgLD(types, target,
+ startFolder, NULL, NULL, titlePtr, extensionFilter);
+ CleanupStack::Pop(extensionFilter);
+ } else if (dialogMode == DialogSave) {
+ select = AknCommonDialogsDynMem::RunSaveDlgLD(types, target,
+ startFolder, NULL, NULL, titlePtr);
+ } else if (dialogMode == DialogFolder) {
+ select = AknCommonDialogsDynMem::RunFolderSelectDlgLD(types, target, startFolder,
+ 0, 0, titlePtr, NULL, NULL);
+ }
+ );
+
+ if (err == KErrNone) {
+ tryCount = 0;
+ } else {
+ // Symbian native file dialog doesn't allow accessing files outside C:/Data
+ // It will always leave in that case, so default into QDir::rootPath() in error cases.
+ QString dir = QDir::toNativeSeparators(QDir::rootPath());
startFolder = qt_QString2TPtrC(dir);
}
- TInt types = AknCommonDialogsDynMem::EMemoryTypeMMCExternal|
- AknCommonDialogsDynMem::EMemoryTypeInternalMassStorage|
- AknCommonDialogsDynMem::EMemoryTypePhone;
-
- TPtrC titlePtr(qt_QString2TPtrC(dialogCaption));
- TFileName target;
- bool select = false;
- if (dialogMode == DialogOpen) {
- CExtensionFilter* extensionFilter = new (ELeave) CExtensionFilter;
- CleanupStack::PushL(extensionFilter);
- extensionFilter->setFilter(filter);
- select = AknCommonDialogsDynMem::RunSelectDlgLD(types, target,
- startFolder, NULL, NULL, titlePtr, extensionFilter);
- CleanupStack::Pop(extensionFilter);
- } else if (dialogMode == DialogSave) {
- select = AknCommonDialogsDynMem::RunSaveDlgLD(types, target,
- startFolder, NULL, NULL, titlePtr);
- } else if (dialogMode == DialogFolder) {
- select = AknCommonDialogsDynMem::RunFolderSelectDlgLD(types, target, startFolder,
- 0, 0, titlePtr, NULL, NULL);
- }
- if (select)
- selection.append(qt_TDesC2QString(target));
- );
+ }
+ if (select)
+ selection.append(qt_TDesC2QString(target));
#endif
return selection;
}
diff --git a/tools/runonphone/serenum_unix.cpp b/tools/runonphone/serenum_unix.cpp
index db6375e..86e797b 100644
--- a/tools/runonphone/serenum_unix.cpp
+++ b/tools/runonphone/serenum_unix.cpp
@@ -82,7 +82,7 @@ QList<SerialPortId> enumerateSerialPorts(int loglevel)
for (struct usb_bus *bus = usb_get_busses(); bus; bus = bus->next) {
for (struct usb_device *device = bus->devices; device; device = device->next) {
- for (int n = 0; n < device->descriptor.bNumConfigurations; ++n) {
+ for (int n = 0; n < device->descriptor.bNumConfigurations && device->config; ++n) {
struct usb_config_descriptor &usbConfig =device->config[n];
QList<int> usableInterfaces;
for (int m = 0; m < usbConfig.bNumInterfaces; ++m) {
@@ -158,6 +158,10 @@ QList<SerialPortId> enumerateSerialPorts(int loglevel)
<< "device" << device->filename
<< "interface" << descriptor.bInterfaceNumber;
}
+#ifdef Q_OS_MAC
+ eligibleInterfaces << QString("^cu\\.usbmodem.*%1$")
+ .arg(QString("%1").arg(descriptor.bInterfaceNumber, 1, 16).toUpper());
+#else
// ### manufacturer and product strings are only readable as root :(
if (!manufacturerString.isEmpty() && !productString.isEmpty()) {
eligibleInterfaces << QString("usb-%1_%2-if%3")
@@ -167,6 +171,7 @@ QList<SerialPortId> enumerateSerialPorts(int loglevel)
} else {
eligibleInterfaces << QString("if%1").arg(i, 2, 16, QChar('0')); // fix!
}
+#endif
eligibleInterfacesInfo << InterfaceInfo(manufacturerString, productString, device->descriptor.idVendor, device->descriptor.idProduct);
}
}
@@ -179,14 +184,24 @@ QList<SerialPortId> enumerateSerialPorts(int loglevel)
if (loglevel > 1)
qDebug() << " searching for interfaces:" << eligibleInterfaces;
+#ifdef Q_OS_MAC
+ QDir dir("/dev/");
+ bool allowAny = false;
+#else
QDir dir("/dev/serial/by-id/");
- foreach (const QFileInfo &info, dir.entryInfoList()) {
+ bool allowAny = eligibleInterfaces.isEmpty();
+#endif
+ foreach (const QFileInfo &info, dir.entryInfoList(QDir::System)) {
if (!info.isDir()) {
- bool usable = eligibleInterfaces.isEmpty();
+ bool usable = allowAny;
+ QString friendlyName = info.fileName();
foreach (const QString &iface, eligibleInterfaces) {
- if (info.fileName().contains(iface)) {
+ if (info.fileName().contains(QRegExp(iface))) {
if (loglevel > 1)
qDebug() << " found device file:" << info.fileName() << endl;
+#ifdef Q_OS_MAC
+ friendlyName = eligibleInterfacesInfo[eligibleInterfaces.indexOf(iface)].product;
+#endif
usable = true;
break;
}
@@ -195,7 +210,7 @@ QList<SerialPortId> enumerateSerialPorts(int loglevel)
continue;
SerialPortId id;
- id.friendlyName = info.fileName();
+ id.friendlyName = friendlyName;
id.portName = info.canonicalFilePath();
list << id;
}
@@ -208,11 +223,15 @@ QList<SerialPortId> enumerateSerialPorts(int loglevel)
<< iface.manufacturer
<< "Product:"
<< iface.product
+#ifdef Q_OS_LINUX
<< endl
<< " Load generic driver using:"
<< QString("sudo modprobe usbserial vendor=0x%1 product=0x%2")
.arg(iface.manufacturerid, 4, 16, QChar('0'))
.arg(iface.productid, 4, 16, QChar('0'));
+#else
+ ;
+#endif
}
}
return list;