changeset 2895:4326939da6ed draft

Merge branch '0.5.0.x' into 0.5.x Conflicts: src/qt/notificator.h
author Luke Dashjr <luke-jr+git@utopios.org>
date Fri, 06 Apr 2012 16:34:34 -0400
parents 44fc2f0d171c (current diff) eb231c32e0c2 (diff)
children d23a41dbeca9
files src/qt/bitcoingui.cpp src/qt/guiutil.h src/qt/notificator.h src/qt/sendcoinsdialog.h
diffstat 8 files changed, 41 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/doc/assets-attribution.txt
+++ b/doc/assets-attribution.txt
@@ -1,3 +1,7 @@
+Code: src/strlcpy.h
+Author: Todd C. Miller <Todd.Miller@courtesan.com>
+License: ISC
+
 Icon: src/qt/res/icons/clock*.png, src/qt/res/icons/tx*.png,
       src/qt/res/src/*.svg
 Designer: Wladimir van der Laan
--- a/src/qt/bitcoingui.cpp
+++ b/src/qt/bitcoingui.cpp
@@ -659,7 +659,7 @@
 
 void BitcoinGUI::dragEnterEvent(QDragEnterEvent *event)
 {
-    // Accept only URLs
+    // Accept only URIs
     if(event->mimeData()->hasUrls())
         event->acceptProposedAction();
 }
@@ -669,10 +669,10 @@
     if(event->mimeData()->hasUrls())
     {
         gotoSendCoinsPage();
-        QList<QUrl> urls = event->mimeData()->urls();
-        foreach(const QUrl &url, urls)
+        QList<QUrl> uris = event->mimeData()->urls();
+        foreach(const QUrl &uri, uris)
         {
-            sendCoinsPage->handleURL(&url);
+            sendCoinsPage->handleURI(&uri);
         }
     }
 
--- a/src/qt/guiutil.cpp
+++ b/src/qt/guiutil.cpp
@@ -47,16 +47,16 @@
     widget->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
 }
 
-bool GUIUtil::parseBitcoinURL(const QUrl *url, SendCoinsRecipient *out)
+bool GUIUtil::parseBitcoinURI(const QUrl *uri, SendCoinsRecipient *out)
 {
-    if(url->scheme() != QString("bitcoin"))
+    if(uri->scheme() != QString("bitcoin"))
         return false;
 
     SendCoinsRecipient rv;
-    rv.address = url->path();
-    rv.label = url->queryItemValue("label");
+    rv.address = uri->path();
+    rv.label = uri->queryItemValue("label");
 
-    QString amount = url->queryItemValue("amount");
+    QString amount = uri->queryItemValue("amount");
     if(amount.isEmpty())
     {
         rv.amount = 0;
@@ -75,18 +75,18 @@
     return true;
 }
 
-bool GUIUtil::parseBitcoinURL(QString url, SendCoinsRecipient *out)
+bool GUIUtil::parseBitcoinURI(QString uri, SendCoinsRecipient *out)
 {
     // Convert bitcoin:// to bitcoin:
     //
     //    Cannot handle this later, because bitcoin:// will cause Qt to see the part after // as host,
     //    which will lowercase it (and thus invalidate the address).
-    if(url.startsWith("bitcoin://"))
+    if(uri.startsWith("bitcoin://"))
     {
-        url.replace(0, 10, "bitcoin:");
+        uri.replace(0, 10, "bitcoin:");
     }
-    QUrl urlInstance(url);
-    return parseBitcoinURL(&urlInstance, out);
+    QUrl uriInstance(uri);
+    return parseBitcoinURI(&uriInstance, out);
 }
 
 QString GUIUtil::getSaveFileName(QWidget *parent, const QString &caption,
--- a/src/qt/guiutil.h
+++ b/src/qt/guiutil.h
@@ -28,10 +28,10 @@
     static void setupAddressWidget(QLineEdit *widget, QWidget *parent);
     static void setupAmountWidget(QLineEdit *widget, QWidget *parent);
 
-    // Parse "bitcoin:" URL into recipient object, return true on succesful parsing
-    // See Bitcoin URL definition discussion here: https://bitcointalk.org/index.php?topic=33490.0
-    static bool parseBitcoinURL(const QUrl *url, SendCoinsRecipient *out);
-    static bool parseBitcoinURL(QString url, SendCoinsRecipient *out);
+    // Parse "bitcoin:" URI into recipient object, return true on succesful parsing
+    // See Bitcoin URI definition discussion here: https://bitcointalk.org/index.php?topic=33490.0
+    static bool parseBitcoinURI(const QUrl *, SendCoinsRecipient *out);
+    static bool parseBitcoinURI(QString uri, SendCoinsRecipient *out);
 
     /** Get save file name, mimics QFileDialog::getSaveFileName, except that it appends a default suffix
         when no suffix is provided by the user.
--- a/src/qt/notificator.cpp
+++ b/src/qt/notificator.cpp
@@ -52,10 +52,13 @@
     OSStatus status = LSGetApplicationForInfo(kLSUnknownType, kLSUnknownCreator, CFSTR("growlTicket"), kLSRolesAll, 0, &cfurl);
     if (status != kLSApplicationNotFoundErr) {
         CFBundleRef bundle = CFBundleCreate(0, cfurl);
+        if (CFStringCompare(CFBundleGetIdentifier(bundle), CFSTR("com.Growl.GrowlHelperApp"), kCFCompareCaseInsensitive | kCFCompareBackwards) == kCFCompareEqualTo) {
+            if (CFStringHasSuffix(CFURLGetString(cfurl), CFSTR("/Growl.app/")))
+                mode = Growl13;
+            else
+                mode = Growl12;
+        }
         CFRelease(cfurl);
-        if (CFStringCompare(CFBundleGetIdentifier(bundle), CFSTR("com.Growl.GrowlHelperApp"), kCFCompareCaseInsensitive | kCFCompareBackwards) == kCFCompareEqualTo) {
-            mode = Growl;
-        }
         CFRelease(bundle);
     }
 #endif
@@ -226,7 +229,7 @@
 void Notificator::notifyGrowl(Class cls, const QString &title, const QString &text, const QIcon &icon)
 {
     const QString script(
-        "tell application \"GrowlHelperApp\"\n"
+        "tell application \"%5\"\n"
         "  set the allNotificationsList to {\"Notification\"}\n" // -- Make a list of all the notification types (all)
         "  set the enabledNotificationsList to {\"Notification\"}\n" // -- Make a list of the notifications (enabled)
         "  register as application \"%1\" all notifications allNotificationsList default notifications enabledNotificationsList\n" // -- Register our script with Growl
@@ -265,7 +268,8 @@
     QString quotedTitle(title), quotedText(text);
     quotedTitle.replace("\\", "\\\\").replace("\"", "\\");
     quotedText.replace("\\", "\\\\").replace("\"", "\\");
-    qt_mac_execute_apple_script(script.arg(notificationApp, quotedTitle, quotedText, notificationIcon), 0);
+    QString growlApp(this->mode == Notificator::Growl13 ? "Growl" : "GrowlHelperApp");
+    qt_mac_execute_apple_script(script.arg(notificationApp, quotedTitle, quotedText, notificationIcon, growlApp), 0);
 }
 #endif
 
@@ -282,7 +286,8 @@
         notifySystray(cls, title, text, icon, millisTimeout);
         break;
 #ifdef Q_WS_MAC
-    case Growl:
+    case Growl12:
+    case Growl13:
         notifyGrowl(cls, title, text, icon);
         break;
 #endif
--- a/src/qt/notificator.h
+++ b/src/qt/notificator.h
@@ -49,7 +49,8 @@
         None,        /**< Ignore informational notifications, and show a modal pop-up dialog for Critical notifications. */
         Freedesktop, /**< Use DBus org.freedesktop.Notifications */
         QSystemTray, /**< Use QSystemTray::showMessage */
-        Growl        /**< Use the Growl notification system (Mac only) */
+        Growl12,        /**< Use the Growl 1.2 notification system (Mac only) */
+        Growl13        /**< Use the Growl 1.3 notification system (Mac only) */
     };
     QString programName;
     Mode mode;
--- a/src/qt/sendcoinsdialog.cpp
+++ b/src/qt/sendcoinsdialog.cpp
@@ -255,20 +255,20 @@
 }
 
 
-void SendCoinsDialog::handleURL(const QUrl *url)
+void SendCoinsDialog::handleURI(const QUrl *uri)
 {
     SendCoinsRecipient rv;
-    if(!GUIUtil::parseBitcoinURL(url, &rv))
+    if(!GUIUtil::parseBitcoinURI(uri, &rv))
     {
         return;
     }
     pasteEntry(rv);
 }
 
-void SendCoinsDialog::handleURL(const QString &url)
+void SendCoinsDialog::handleURI(const QString &uri)
 {
     SendCoinsRecipient rv;
-    if(!GUIUtil::parseBitcoinURL(url, &rv))
+    if(!GUIUtil::parseBitcoinURI(uri, &rv))
     {
         return;
     }
--- a/src/qt/sendcoinsdialog.h
+++ b/src/qt/sendcoinsdialog.h
@@ -30,8 +30,8 @@
     QWidget *setupTabChain(QWidget *prev);
 
     void pasteEntry(const SendCoinsRecipient &rv);
-    void handleURL(const QUrl *url);
-    void handleURL(const QString &url);
+    void handleURI(const QUrl *uri);
+    void handleURI(const QString &uri);
 
 public slots:
     void clear();