fixed some issues and make compile with msvc10
This commit is contained in:
parent
ce59e355a2
commit
e2d0bc6d09
|
@ -40,6 +40,9 @@ if (CMAKE_COMPILER_IS_GNUCXX)
|
|||
|
||||
endif(CMAKE_COMPILER_IS_GNUCXX)
|
||||
|
||||
if(MSVC)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:wchar_t-")
|
||||
endif(MSVC)
|
||||
|
||||
option(WITH_FREEDESKTOP_FRONTEND "Build the freedesktop frontend" OFF)
|
||||
option(WITH_WEBINTERFACE "Buld with WebInterface" OFF)
|
||||
|
|
|
@ -74,7 +74,7 @@ const uint &Notification::id() const
|
|||
return _id;
|
||||
}
|
||||
|
||||
const QString &Notification::Notification::icon() const
|
||||
const QString &Notification::icon() const
|
||||
{
|
||||
return _icon;
|
||||
}
|
||||
|
|
|
@ -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 "snarl_backend.h"
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
|||
#include <QtCore>
|
||||
#include <QTextEdit>
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include <wchar.h>
|
||||
|
||||
|
@ -29,96 +30,98 @@
|
|||
|
||||
Q_EXPORT_PLUGIN2(snarl_backend,Snarl_Backend)
|
||||
|
||||
Snarl_Backend::Snarl_Backend(SnoreServer *snore):
|
||||
Snarl_Backend::Snarl_Backend(SnoreServer *snore):
|
||||
Notification_Backend("SnarlBackend",snore)
|
||||
{
|
||||
Snarl::SnarlInterface *snarlInterface = new Snarl::SnarlInterface();
|
||||
_applications.insert("SnoreNotify",snarlInterface);
|
||||
qDebug()<<"Initiating Snarl Backend, Snarl version: "<<snarlInterface->GetVersionExA();
|
||||
_defautSnarlinetrface = new Snarl::SnarlInterface();
|
||||
this->installEventFilter(this);
|
||||
Snarl::SnarlInterface *snarlInterface = new Snarl::SnarlInterface();
|
||||
_applications.insert("SnoreNotify",snarlInterface);
|
||||
qDebug()<<"Initiating Snarl Backend, Snarl version: "<<snarlInterface->GetVersionExA();
|
||||
_defautSnarlinetrface = new Snarl::SnarlInterface();
|
||||
this->installEventFilter(this);
|
||||
|
||||
|
||||
}
|
||||
Snarl_Backend::~Snarl_Backend(){
|
||||
|
||||
foreach(Application *a,this->snore()->aplications().values()){
|
||||
unregisterApplication(a);
|
||||
}
|
||||
delete _defautSnarlinetrface;
|
||||
foreach(Application *a,this->snore()->aplications().values()){
|
||||
unregisterApplication(a);
|
||||
}
|
||||
delete _defautSnarlinetrface;
|
||||
}
|
||||
|
||||
void Snarl_Backend::registerApplication(Application *application){
|
||||
Snarl::SnarlInterface *snarlInterface = new Snarl::SnarlInterface();
|
||||
_applications.insert(application->name(),snarlInterface);
|
||||
Snarl::SnarlInterface *snarlInterface = new Snarl::SnarlInterface();
|
||||
_applications.insert(application->name(),snarlInterface);
|
||||
|
||||
wchar_t *appName = toWchar(application->name());
|
||||
wchar_t *icon = toWchar(application->icon());
|
||||
snarlInterface->RegisterApp(appName,icon,icon);
|
||||
wchar_t *appName = toWchar(application->name());
|
||||
wchar_t *icon = toWchar(application->icon());
|
||||
snarlInterface->RegisterApp(appName,icon,icon);
|
||||
|
||||
foreach(Alert *alert,application->alerts()){
|
||||
wchar_t *alertName = toWchar(alert->name());
|
||||
snarlInterface->RegisterAlert(appName,alertName);
|
||||
delete [] alertName;
|
||||
}
|
||||
delete [] appName;
|
||||
delete [] icon;
|
||||
foreach(Alert *alert,application->alerts()){
|
||||
wchar_t *alertName = toWchar(alert->name());
|
||||
snarlInterface->RegisterAlert(appName,alertName);
|
||||
delete [] alertName;
|
||||
}
|
||||
delete [] appName;
|
||||
delete [] icon;
|
||||
}
|
||||
|
||||
void Snarl_Backend::unregisterApplication(Application *application){
|
||||
Snarl::SnarlInterface *snarlInterface = _applications.take(application->name());
|
||||
if(snarlInterface == NULL)
|
||||
return;
|
||||
snarlInterface->UnregisterApp();
|
||||
delete snarlInterface;
|
||||
Snarl::SnarlInterface *snarlInterface = _applications.take(application->name());
|
||||
if(snarlInterface == NULL)
|
||||
return;
|
||||
snarlInterface->UnregisterApp();
|
||||
delete snarlInterface;
|
||||
}
|
||||
|
||||
int Snarl_Backend::notify(QSharedPointer<Notification>notification){
|
||||
Snarl::SnarlInterface *snarlInterface = _applications.value(notification->application());
|
||||
if(snarlInterface == NULL)
|
||||
snarlInterface = _defautSnarlinetrface;
|
||||
Snarl::SnarlInterface *snarlInterface = _applications.value(notification->application());
|
||||
if(snarlInterface == NULL)
|
||||
snarlInterface = _defautSnarlinetrface;
|
||||
|
||||
wchar_t *title = toWchar(Notification::toPlainText(notification->title()));
|
||||
wchar_t *text = toWchar(Notification::toPlainText(notification->text()));
|
||||
wchar_t *icon = toWchar(notification->icon());
|
||||
int id = notification->id();
|
||||
wchar_t *title = toWchar(Notification::toPlainText(notification->title()));
|
||||
wchar_t *text = toWchar(Notification::toPlainText(notification->text()));
|
||||
wchar_t *icon = toWchar(notification->icon());
|
||||
|
||||
if(notification->id()==0){
|
||||
wprintf(L"Calling SnarlMessage\n"
|
||||
L"Title: \"%s\"\n"
|
||||
L"Text: \"%s\"\n"
|
||||
L"Timeout: \"%i\"\n"
|
||||
L"Icon: \"%s\"\n",title,text,notification->timeout(),icon);
|
||||
return snarlInterface->ShowMessage(title,text,notification->timeout(), icon);
|
||||
}else{
|
||||
//update message
|
||||
wprintf(L"Updating SnarlMessage ID: \"%i\"\n"
|
||||
L"Title: \"%s\"\n"
|
||||
L"Text: \"%s\"\n"
|
||||
L"Icon: \"%s\"\n",notification->id(),title,text,icon);
|
||||
snarlInterface->UpdateMessage(notification->id(),title, text,icon);
|
||||
return notification->id();
|
||||
}
|
||||
delete[] title;
|
||||
delete[] text;
|
||||
delete[] icon;
|
||||
if(notification->id()==0){
|
||||
wprintf(L"Calling SnarlMessage\n"
|
||||
L"Title: \"%s\"\n"
|
||||
L"Text: \"%s\"\n"
|
||||
L"Timeout: \"%i\"\n"
|
||||
L"Icon: \"%s\"\n",title,text,notification->timeout(),icon);
|
||||
id = snarlInterface->ShowMessage(title,text,notification->timeout(), icon);
|
||||
}else{
|
||||
//update message
|
||||
wprintf(L"Updating SnarlMessage ID: \"%i\"\n"
|
||||
L"Title: \"%s\"\n"
|
||||
L"Text: \"%s\"\n"
|
||||
L"Icon: \"%s\"\n",notification->id(),title,text,icon);
|
||||
snarlInterface->UpdateMessage(notification->id(),title, text,icon);
|
||||
}
|
||||
|
||||
delete[] title;
|
||||
delete[] text;
|
||||
delete[] icon;
|
||||
return id;
|
||||
}
|
||||
|
||||
void Snarl_Backend::closeNotification(QSharedPointer<Notification> notification){
|
||||
Snarl::SnarlInterface *snarlInterface = _applications.value(notification->application());
|
||||
if(snarlInterface == NULL)
|
||||
return;
|
||||
snarlInterface->HideMessage(notification->id());
|
||||
Snarl::SnarlInterface *snarlInterface = _applications.value(notification->application());
|
||||
if(snarlInterface == NULL)
|
||||
return;
|
||||
snarlInterface->HideMessage(notification->id());
|
||||
}
|
||||
|
||||
bool Snarl_Backend::eventFilter(QObject *obj, QEvent *event){
|
||||
qDebug()<<obj->objectName();
|
||||
return true;
|
||||
qDebug()<<obj->objectName();
|
||||
return true;
|
||||
}
|
||||
|
||||
wchar_t *Snarl_Backend::toWchar(const QString &string){
|
||||
wchar_t *wc = new wchar_t[string.length()+1];
|
||||
wc[string.toWCharArray(wc)] = 0;
|
||||
return wc;
|
||||
wchar_t *wc = new wchar_t[string.length() + 1];
|
||||
wc[string.toWCharArray(wc)] = 0;
|
||||
return wc;
|
||||
}
|
||||
|
||||
#include "snarl_backend.moc"
|
||||
|
|
Loading…
Reference in New Issue