Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mumble-voip/mumble.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMikkel Krautz <mikkel@krautz.dk>2009-11-26 01:28:12 +0300
committerMikkel Krautz <mikkel@krautz.dk>2009-11-26 01:28:23 +0300
commite0e8bc0956b44ed3171ef4acc265ae05ac31fd12 (patch)
treef895dcd2e4048d00f25bdafc3e87c9a783405bda /src
parenta22567a02c48bcdea43f8c3b51207d01a5c19daf (diff)
Fix OSX compatibility client launching and URL handling for unversioned and ?version=1.1.x URLs.
Diffstat (limited to 'src')
-rw-r--r--src/mumble/MainWindow.cpp82
-rw-r--r--src/mumble/MainWindow.h9
-rw-r--r--src/mumble/main.cpp6
-rw-r--r--src/mumble11x/mumble11x.plist11
4 files changed, 80 insertions, 28 deletions
diff --git a/src/mumble/MainWindow.cpp b/src/mumble/MainWindow.cpp
index 56bc7f39d..4a903c33f 100644
--- a/src/mumble/MainWindow.cpp
+++ b/src/mumble/MainWindow.cpp
@@ -106,6 +106,10 @@ MessageBoxEvent::MessageBoxEvent(QString m) : QEvent(static_cast<QEvent::Type>(M
msg = m;
}
+OpenURLEvent::OpenURLEvent(QUrl u) : QEvent(static_cast<QEvent::Type>(OU_QEVENT)) {
+ url = u;
+}
+
MainWindow::MainWindow(QWidget *p) : QMainWindow(p) {
qiIconMuteSelf.addFile(QLatin1String("skin:muted_self.svg"));
qiIconMuteServer.addFile(QLatin1String("skin:muted_server.svg"));
@@ -431,6 +435,12 @@ void MainWindow::openUrl(const QUrl &url) {
patch = rx.cap(3).toInt();
}
+#ifdef Q_OS_MAC
+ if ((major == 1) && (minor == 1)) {
+ launchCompatibilityClient(url);
+ return;
+ } else
+#endif
if ((major != 1) || (minor != 2) || (patch > 0)) {
g.l->log(Log::Warning, tr("This version of Mumble can't handle URLs for Mumble version %1.%2.%3").arg(major).arg(minor).arg(patch));
return;
@@ -1829,7 +1839,6 @@ void MainWindow::serverDisconnected(QAbstractSocket::SocketError err, QString re
}
}
}
-#ifdef USE_DBUS
else if (err == QAbstractSocket::SslHandshakeFailedError) {
if (QMessageBox::warning(this, tr("SSL Version mismatch"), tr("This server is using an older encryption standard. It might be an older 1.1 based Mumble server.<br />Would you like to launch the compatibility client to connect to it?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes) == QMessageBox::Yes) {
@@ -1846,28 +1855,20 @@ void MainWindow::serverDisconnected(QAbstractSocket::SocketError err, QString re
QDBusInterface qdbi(QLatin1String("net.sourceforge.mumble.mumble11x"), QLatin1String("/"), QLatin1String("net.sourceforge.mumble.Mumble"));
+#ifdef USE_DBUS
QDBusMessage reply=qdbi.call(QLatin1String("openUrl"), QLatin1String(url.toEncoded()));
if (reply.type() == QDBusMessage::ReplyMessage) {
this->close();
return;
- } else {
- QString executable = QApplication::instance()->applicationFilePath();
- int idx = executable.lastIndexOf(QLatin1String("mumble"));
- if (idx >= 0) {
- QStringList args;
- args << url.toString();
-
- executable.replace(idx, 6, QLatin1String("mumble11x"));
- if (QProcess::startDetached(executable, args))
- this->close();
+ } else
+#endif
+ {
+ if (launchCompatibilityClient(url))
return;
- }
}
QMessageBox::critical(this, tr("Failed to launch compatibility client"), tr("The compatibility client could not be found, or failed to start.<br />Note that the compatibility client is an optional component for most installations, and might not be installed."), QMessageBox::Ok, QMessageBox::Ok);
}
- }
-#endif
- else {
+ } else {
bool ok = false;
bool matched = false;
@@ -1999,6 +2000,10 @@ void MainWindow::customEvent(QEvent *evt) {
MessageBoxEvent *mbe=static_cast<MessageBoxEvent *>(evt);
g.l->log(Log::Information, mbe->msg);
return;
+ } else if (evt->type() == OU_QEVENT) {
+ OpenURLEvent *oue=static_cast<OpenURLEvent *>(evt);
+ openUrl(oue->url);
+ return;
} else if (evt->type() != SERVERSEND_EVENT) {
return;
}
@@ -2088,3 +2093,50 @@ QPair<QByteArray, QImage> MainWindow::openImageFile() {
return retval;
}
+
+bool MainWindow::launchCompatibilityClient(const QUrl &url) {
+#ifdef Q_OS_MAC
+ FSRef fref;
+ OSStatus err;
+
+ err = LSFindApplicationForInfo(kLSUnknownCreator, CFSTR("net.sourceforge.mumble.Mumble11x"), CFSTR("Mumble11x.app"), &fref, NULL);
+ if (err == noErr) {
+ CFMutableArrayRef arguments = CFArrayCreateMutable(kCFAllocatorDefault, 2, &kCFTypeArrayCallBacks);
+ if (arguments) {
+ CFArrayAppendValue(arguments, CFSTR("Mumble11x"));
+ QString qsUrlString = url.toString();
+ CFStringRef urlString = CFStringCreateWithCharacters(kCFAllocatorDefault, reinterpret_cast<const UniChar *>(qsUrlString.unicode()), qsUrlString.length());
+ CFArrayAppendValue(arguments, urlString);
+ CFRelease(urlString);
+ }
+
+ LSApplicationParameters parm;
+ memset(&parm, 0, sizeof(LSApplicationParameters));
+ parm.flags = kLSLaunchDefaults;
+ parm.application = &fref;
+ parm.argv = arguments;
+ err = LSOpenApplication(&parm, NULL);
+
+ CFRelease(arguments);
+
+ if (err == noErr) {
+ this->close();
+ return true;
+ }
+ }
+#else
+ QString executable = QApplication::instance()->applicationFilePath();
+ int idx = executable.lastIndexOf(QLatin1String("mumble"));
+ if (idx >= 0) {
+ QStringList args;
+ args << url.toString();
+
+ executable.replace(idx, 6, QLatin1String("mumble11x"));
+ if (QProcess::startDetached(executable, args))
+ this->close();
+ return true;
+ }
+#endif
+
+ return false;
+}
diff --git a/src/mumble/MainWindow.h b/src/mumble/MainWindow.h
index 935afd637..627f768b8 100644
--- a/src/mumble/MainWindow.h
+++ b/src/mumble/MainWindow.h
@@ -36,6 +36,7 @@
#define TI_QEVENT (QEvent::User + 938)
#define MB_QEVENT (QEvent::User + 939)
+#define OU_QEVENT (QEvent::User + 940)
class ACLEditor;
class BanEditor;
@@ -60,6 +61,12 @@ class MessageBoxEvent : public QEvent {
MessageBoxEvent(QString msg);
};
+class OpenURLEvent : public QEvent {
+ public:
+ QUrl url;
+ OpenURLEvent(QUrl url);
+};
+
class MainWindow : public QMainWindow, public MessageHandler, public Ui::MainWindow {
friend class UserModel;
private:
@@ -92,6 +99,7 @@ class MainWindow : public QMainWindow, public MessageHandler, public Ui::MainWin
void setOnTop(bool top);
void updateTrayIcon();
QPair<QByteArray, QImage> openImageFile();
+
#ifdef Q_OS_WIN
bool winEvent(MSG *, long *);
unsigned int uiNewHardware;
@@ -116,6 +124,7 @@ class MainWindow : public QMainWindow, public MessageHandler, public Ui::MainWin
void findDesiredChannel();
void setupView(bool toggle_minimize = true);
void setupIconMenu(bool top = false);
+ bool launchCompatibilityClient(const QUrl &url);
bool bNoHide;
virtual void closeEvent(QCloseEvent *e);
virtual void hideEvent(QHideEvent *e);
diff --git a/src/mumble/main.cpp b/src/mumble/main.cpp
index 3861b9d8e..87dc89876 100644
--- a/src/mumble/main.cpp
+++ b/src/mumble/main.cpp
@@ -323,10 +323,12 @@ int main(int argc, char **argv) {
g.p->checkUpdates();
if (url.isValid()) {
- g.mw->openUrl(url);
+ OpenURLEvent *oue = new OpenURLEvent(url);
+ qApp->postEvent(g.mw, oue);
#ifdef Q_OS_MAC
} else if (os_url) {
- g.mw->openUrl(QUrl::fromEncoded(QByteArray(os_url)));
+ OpenURLEvent *oue = new OpenURLEvent(QUrl::fromEncoded(QByteArray(os_url)));
+ qApp->postEvent(g.mw, oue);
#endif
} else {
g.mw->on_qaServerConnect_triggered();
diff --git a/src/mumble11x/mumble11x.plist b/src/mumble11x/mumble11x.plist
index c0a1e105a..2d2587857 100644
--- a/src/mumble11x/mumble11x.plist
+++ b/src/mumble11x/mumble11x.plist
@@ -14,17 +14,6 @@
<string>APPL</string>
<key>CFBundleSignature</key>
<string>MBLE</string>
- <key>CFBundleURLTypes</key>
- <array>
- <dict>
- <key>CFBundleURLName</key>
- <string>Mumble Server URL</string>
- <key>CFBundleURLSchemes</key>
- <array>
- <string>mumble</string>
- </array>
- </dict>
- </array>
<key>CFBundleVersion</key>
<string>1.1.x</string>
<key>NSHumanReadableCopyright</key>