bool GrowlManager::onLLNotification(const LLSD& notice) { if(notice["sigtype"].asString() != "add") return false; static BOOL* enabled = rebind_llcontrol<BOOL>("PhoenixEnableGrowl", &gSavedSettings, true); if(!*enabled) return false; if(!shouldNotify()) return false; LLNotificationPtr notification = LLNotifications::instance().find(notice["id"].asUUID()); std::string name = notification->getName(); LLSD substitutions = notification->getSubstitutions(); if(LLStartUp::getStartupState() < STATE_STARTED) { LL_WARNS("GrowlLLNotification") << "GrowlManager discarded a notification (" << name << ") - too early." << LL_ENDL; return false; } if(gGrowlManager->mNotifications.find(name) != gGrowlManager->mNotifications.end()) { GrowlNotification* growl_notification = &gGrowlManager->mNotifications[name]; std::string body = ""; std::string title = ""; if(growl_notification->useDefaultTextForTitle) title = notification->getMessage(); else if(growl_notification->growlTitle != "") title = LLNotification::format(growl_notification->growlTitle, substitutions); if(growl_notification->useDefaultTextForBody) body = notification->getMessage(); else if(growl_notification->growlBody != "") body = LLNotification::format(growl_notification->growlBody, substitutions); LL_INFOS("GrowlLLNotification") << "Notice: " << title << ": " << body << LL_ENDL; gGrowlManager->notify(title, body, growl_notification->growlName); } return false; }
void GrowlManager::notify(const std::string& notification_title, const std::string& notification_message, const std::string& notification_type) { static BOOL* enabled = rebind_llcontrol<BOOL>("PhoenixEnableGrowl", &gSavedSettings, true); if(!*enabled) return; if(!shouldNotify()) return; if(this->mNotifier->needsThrottle()) { U64 now = LLTimer::getTotalTime(); if(mTitleTimers.find(notification_title) != mTitleTimers.end()) { if(mTitleTimers[notification_title] > now - GROWL_THROTTLE_TIME) { LL_WARNS("GrowlNotify") << "Discarded notification with title '" << notification_title << "' - spam ._." << LL_ENDL; mTitleTimers[notification_title] = now; return; } } mTitleTimers[notification_title] = now; } this->mNotifier->showNotification(notification_title, notification_message.substr(0, GROWL_MAX_BODY_LENGTH), notification_type); }
//static bool KVGrowlManager::onLLNotification(const LLSD& notice) { if(notice["sigtype"].asString() != "add") return false; if(!shouldNotify()) return false; LLNotificationPtr notification = LLNotifications::instance().find(notice["id"].asUUID()); std::string name = notification->getName(); LLSD substitutions = notification->getSubstitutions(); if(LLStartUp::getStartupState() < STATE_STARTED) { LL_WARNS("GrowlLLNotification") << "GrowlManager discarded a notification (" << name << ") - too early." << LL_ENDL; return false; } if(gGrowlManager->mNotifications.find(name) != gGrowlManager->mNotifications.end()) { KVGrowlNotification* growl_notification = &gGrowlManager->mNotifications[name]; std::string body = ""; std::string title = ""; if(growl_notification->useDefaultTextForTitle) title = notification->getMessage(); else if(growl_notification->growlTitle != "") title = growl_notification->growlTitle; LLStringUtil::format(title, substitutions); if(growl_notification->useDefaultTextForBody) body = notification->getMessage(); else if(growl_notification->growlBody != "") body = growl_notification->growlBody; LLStringUtil::format(body, substitutions); gGrowlManager->notify(title, body, growl_notification->growlName); } return false; }
void GrowlManager::notify(const std::string& notification_title, const std::string& notification_message, const std::string& notification_type) { static LLCachedControl<bool> enabled(gSavedSettings, "FSEnableGrowl"); if (!enabled) { return; } if (!shouldNotify()) { return; } if (mNotifier->needsThrottle()) { U64 now = LLTimer::getTotalTime(); if (mTitleTimers.find(notification_title) != mTitleTimers.end()) { if (mTitleTimers[notification_title] > now - GROWL_THROTTLE_TIME) { LL_WARNS("GrowlNotify") << "Discarded notification with title '" << notification_title << "' - spam ._." << LL_ENDL; mTitleTimers[notification_title] = now; return; } } mTitleTimers[notification_title] = now; } mNotifier->showNotification(notification_title, notification_message.substr(0, GROWL_MAX_BODY_LENGTH), notification_type); }
void KVGrowlManager::notify(const std::string& notification_title, const std::string& notification_message, const std::string& notification_type) { if(!shouldNotify()) return; if(!gSavedSettings.getBOOL("KittyEnableGrowl")) return; if(this->mNotifier->needsThrottle()) { U64 now = LLTimer::getTotalTime(); if(mTitleTimers.find(notification_title) != mTitleTimers.end()) { if(mTitleTimers[notification_title] > now - GROWL_THROTTLE_TIME) { LL_WARNS("GrowlNotify") << "Discarded notification with title '" << notification_title << "' - spam." << LL_ENDL; mTitleTimers[notification_title] = now; return; } } mTitleTimers[notification_title] = now; } this->mNotifier->showNotification(notification_title, notification_message.substr(0, GROWL_MAX_BODY_LENGTH), notification_type); }