/** * Constructs a GrowlNotifier. * * \param notifications the list names of all notifications that can be sent * by this notifier. * \param default_notifications the list of names of the notifications that * should be enabled by default. * \param app the name of the application under which the notifier should * register with growl. */ GrowlNotifier::GrowlNotifier( const QStringList& notifications, const QStringList& default_notifications, const QString& app) { // Initialize signaler signaler_ = new GrowlNotifierSignaler(); // All Notifications QStringList::ConstIterator it; CFMutableArrayRef allNotifications = CFArrayCreateMutable( kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks); for ( it = notifications.begin(); it != notifications.end(); ++it ) CFArrayAppendValue(allNotifications, qString2CFString(*it)); // Default Notifications CFMutableArrayRef defaultNotifications = CFArrayCreateMutable( kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks); for ( it = default_notifications.begin(); it != default_notifications.end(); ++it ) CFArrayAppendValue(defaultNotifications, qString2CFString(*it)); // Initialize delegate InitGrowlDelegate(&delegate_); if (!app.isEmpty()) delegate_.applicationName = qString2CFString(app); CFTypeRef keys[] = { GROWL_NOTIFICATIONS_ALL, GROWL_NOTIFICATIONS_DEFAULT }; CFTypeRef values[] = { allNotifications, defaultNotifications }; delegate_.registrationDictionary = CFDictionaryCreate( kCFAllocatorDefault, keys, values, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); delegate_.growlNotificationWasClicked = ¬ification_clicked; delegate_.growlNotificationTimedOut = ¬ification_timeout; // Register with Growl Growl_SetDelegate(&delegate_); }
/** Installe le support de Growl */ void RzxNotifier::installGrowlSupport() { growlDelegate = new Growl_Delegate; InitGrowlDelegate(growlDelegate); // Nom du programme pour Growl growlDelegate->applicationName = CFSTR("qRezix"); // Génère la liste des notifications envisageables CFMutableArrayRef allNotifications = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks); CFArrayAppendValue(allNotifications, CFSTR("Connection State Change")); CFArrayAppendValue(allNotifications, CFSTR("Chat")); CFArrayAppendValue(allNotifications, CFSTR("Notification")); CFArrayRef defaultNotifications = (CFArrayRef)CFRetain(allNotifications); // Génère la configuration du programme const void *keys[] = { GROWL_NOTIFICATIONS_ALL, GROWL_NOTIFICATIONS_DEFAULT }; const void *values[] = { allNotifications, defaultNotifications }; growlDelegate->registrationDictionary = CFDictionaryCreate(kCFAllocatorDefault, keys, values, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); Growl_SetDelegate(growlDelegate); }
struct Growl_Delegate * bmx_Growl_Delegate_create() { struct Growl_Delegate * delegate = new struct Growl_Delegate(); InitGrowlDelegate(delegate); return delegate; }