/**
 * 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 = &notification_clicked;
	delegate_.growlNotificationTimedOut = &notification_timeout;

	// Register with Growl
	Growl_SetDelegate(&delegate_);
}
예제 #2
0
/** 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);
}
예제 #3
0
파일: glue.cpp 프로젝트: Chaduke/bah.mod
Boolean bmx_Growl_SetDelegate(struct Growl_Delegate *newDelegate) {
	return Growl_SetDelegate(newDelegate);
}
예제 #4
0
void growl_init(void)
{

	struct Growl_Delegate * delegateObject;

	CFStringRef applicationName;
	CFStringRef identifierString;
	CFDataRef icon = NULL;
	CFMutableStringRef iconPath = CFStringCreateMutable(kCFAllocatorDefault, 0);
 	char *home = getenv( "HOME" );
	
	applicationName = CFSTR("growl-irssi");
	identifierString = NULL;

	CFStringAppendCString(iconPath, home, kCFStringEncodingUTF8);
	CFStringAppend(iconPath, CFSTR("/.irssi/irssi.icns"));
	
	icon = (CFDataRef)copyIconData(iconPath);
	
	CFSafeRelease(iconPath);
	// Can't register console app growl without icon data so don't even try
	g_return_if_fail(icon != NULL);
	
	CFStringRef name = NOTIFICATION_NAME;
	CFArrayRef defaultAndAllNotifications = CFArrayCreate(kCFAllocatorDefault, (const void **)&name, 1, &kCFTypeArrayCallBacks);
	CFTypeRef registerKeys[4] = {
		GROWL_APP_NAME,
		GROWL_NOTIFICATIONS_ALL,
		GROWL_NOTIFICATIONS_DEFAULT,
		GROWL_APP_ICON,
		// GROWL_APP_ID
	};
	CFTypeRef registerValues[4] = {
		applicationName,
		defaultAndAllNotifications,
		defaultAndAllNotifications,
		icon
	};
	
	CFDictionaryRef registerInfo = CFDictionaryCreate(kCFAllocatorDefault, registerKeys, registerValues, 4, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
	
	delegateObject = (struct Growl_Delegate *)calloc(1, sizeof(struct Growl_Delegate));
	delegateObject->applicationName = CFSTR("growl-irssi");
	delegateObject->registrationDictionary = registerInfo;
	delegateObject->applicationIconData = icon;
	
	
	Growl_SetDelegate(delegateObject);


	CFRelease(defaultAndAllNotifications);
	CFRelease(icon);
	CFRelease(applicationName);

	// Setup irssi
	signal_add_last("message private", (SIGNAL_FUNC) message_incoming);
	signal_add_last("message public", (SIGNAL_FUNC) message_public);
	command_bind("growlhelp", NULL, (SIGNAL_FUNC) command_helpgrowl);
	command_bind("helpgrowl", NULL, (SIGNAL_FUNC) command_helpgrowl);
	// Growl_NotifyWithTitleDescriptionNameIconPriorityStickyClickContext(CFSTR("growl-irssi"), CFSTR("Plugin successfully loaded."), NOTIFICATION_NAME, NULL,	0, FALSE, NULL);

	printtext(NULL, NULL, MSGLEVEL_CLIENTNOTICE,
		"Growl Support successfully loaded\n"
		"Try /helpgrowl or /growlhelp for a short command overview");

	module_register("growl", "core");	
}