app icons for all regist calls, added non encrypted regist version with support for multiple alerts

This commit is contained in:
Patrick von Reth 2011-07-24 13:31:08 +02:00
parent 7e34fbaecf
commit d0956594a9
3 changed files with 56 additions and 34 deletions

View File

@ -52,6 +52,7 @@ void FreedesktopNotification_Frontend::notificationClosed(Notification notificat
qDebug()<<"Closing Dbus notification"<<notification.id()<<"reason:"<<(int)notification.closeReason();
activeNotifications.remove(notification.id());
qDebug()<<"Active Dbus Notifications"<<activeNotifications.keys();
emit NotificationClosed(notification.id(),notification.closeReason());
}
@ -106,6 +107,7 @@ uint FreedesktopNotification_Frontend::Notify(const QString &app_name, uint repl
void FreedesktopNotification_Frontend::CloseNotification(uint id){
Notification noti = activeNotifications.take(id);
qDebug()<<"Active Dbus Notifications"<<activeNotifications.keys();
snore()->closeNotification(noti,NotificationEnums::CloseReasons::TIMED_OUT);
}

View File

@ -184,6 +184,19 @@ public:
send("REGISTER", stm);
}
void regist(const std::vector<std::string> names) throw (std::runtime_error) {
std::stringstream stm;
stm << "Application-Name: " << sanitize_text(application_) << "\r\n";
stm << "Application-Icon: " << sanitize_text(icon_) <<"\r\n";
stm << "Notifications-Count: " << names.size() << "\r\n";
stm << "\r\n";
std::vector<std::string>::const_iterator it;
for (it = names.begin(); it != names.end(); it++) {
make_regist(stm, it->c_str());
}
send("REGISTER", stm);
}
template<class CIPHER_TYPE, class HASH_TYPE>
void regist(const char* name) throw (std::runtime_error) {
std::stringstream stm;
@ -199,6 +212,7 @@ public:
void regist(const std::vector<std::string> names) throw (std::runtime_error) {
std::stringstream stm;
stm << "Application-Name: " << sanitize_text(application_) << "\r\n";
stm << "Application-Icon: " << sanitize_text(icon_) <<"\r\n";
stm << "Notifications-Count: " << names.size() << "\r\n";
stm << "\r\n";
std::vector<std::string>::const_iterator it;

View File

@ -1,18 +1,18 @@
/****************************************************************************************
* Copyright (c) 2010 Patrick von Reth <patrick.vonreth@gmail.com> *
* *
* This program is free software; you can redistribute it and/or modify it under *
* the terms of the GNU General Public License as published by the Free Software *
* Foundation; either version 2 of the License, or (at your option) any later *
* version. *
* *
* This program is distributed in the hope that it will be useful, but WITHOUT ANY *
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A *
* PARTICULAR PURPOSE. See the GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License along with *
* this program. If not, see <http://www.gnu.org/licenses/>. *
****************************************************************************************/
* Copyright (c) 2010 Patrick von Reth <patrick.vonreth@gmail.com> *
* *
* This program is free software; you can redistribute it and/or modify it under *
* the terms of the GNU General Public License as published by the Free Software *
* Foundation; either version 2 of the License, or (at your option) any later *
* version. *
* *
* This program is distributed in the hope that it will be useful, but WITHOUT ANY *
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A *
* PARTICULAR PURPOSE. See the GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License along with *
* this program. If not, see <http://www.gnu.org/licenses/>. *
****************************************************************************************/
#include "growl_backend.h"
#include "gntp.h"
@ -22,44 +22,50 @@
#include <QtCore>
#include <boost/asio.hpp>
Q_EXPORT_PLUGIN2(growl_backend,Growl_Backend)
Growl_Backend::Growl_Backend(SnoreServer *snore):
Growl_Backend::Growl_Backend(SnoreServer *snore):
Notification_Backend("Growl",snore),
id(0)
id(0)
{
}
Growl_Backend::~Growl_Backend(){
foreach(Application *a,this->snore()->aplications().values()){
unregisterApplication(a);
}
foreach(Application *a,this->snore()->aplications().values()){
unregisterApplication(a);
}
qDebug()<<"Growl_Backend bye bye";
}
void Growl_Backend::registerApplication(Application *application){
gntp *growl = new gntp(application->name().toUtf8().constData(),application->icon().localUrl().toUtf8().constData());
std::vector<std::string> alerts;
foreach(Alert *a,application->alerts()){
try{
growl->regist(a->name().toUtf8().constData());
}catch(const std::exception& e){
qDebug()<<"Growl:"<<e.what();
}
alerts.push_back(a->name().toUtf8().constData());
}
_applications.insert(application->name(),growl);
try{
growl->regist(alerts);
}catch(const std::exception& e){
qDebug()<<"Growl:"<<e.what();
}
_applications.insert(application->name(),growl);
}
void Growl_Backend::unregisterApplication(Application *application){
gntp *growl = _applications.take(application->name());
if(growl == NULL)
return;
delete growl;
gntp *growl = _applications.take(application->name());
if(growl == NULL)
return;
delete growl;
}
int Growl_Backend::notify(Notification notification){
gntp *growl = _applications.value(notification.application());
if(growl == NULL)
return -1;
gntp *growl = _applications.value(notification.application());
if(growl == NULL)
return -1;
//qDebug()<<"Notify Growl:"<<notification.application()<<Notification.toPlainText(notification.title());
try{
@ -69,11 +75,11 @@ int Growl_Backend::notify(Notification notification){
notification.icon().localUrl().isEmpty()?NULL:notification.icon().localUrl().toUtf8().constData());
}catch(const std::exception& e){
}
return ++id;
return ++id;
}
void Growl_Backend::closeNotification(Notification notification){
Q_UNUSED(notification);
Q_UNUSED(notification);
}
#include "growl_backend.moc"