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)
|
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_FREEDESKTOP_FRONTEND "Build the freedesktop frontend" OFF)
|
||||||
option(WITH_WEBINTERFACE "Buld with WebInterface" OFF)
|
option(WITH_WEBINTERFACE "Buld with WebInterface" OFF)
|
||||||
|
|
|
@ -74,7 +74,7 @@ const uint &Notification::id() const
|
||||||
return _id;
|
return _id;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString &Notification::Notification::icon() const
|
const QString &Notification::icon() const
|
||||||
{
|
{
|
||||||
return _icon;
|
return _icon;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
/****************************************************************************************
|
/****************************************************************************************
|
||||||
* Copyright (c) 2010 Patrick von Reth <patrick.vonreth@gmail.com> *
|
* Copyright (c) 2010 Patrick von Reth <patrick.vonreth@gmail.com> *
|
||||||
* *
|
* *
|
||||||
* This program is free software; you can redistribute it and/or modify it under *
|
* 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 *
|
* 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 *
|
* Foundation; either version 2 of the License, or (at your option) any later *
|
||||||
* version. *
|
* version. *
|
||||||
* *
|
* *
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY *
|
* 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 *
|
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A *
|
||||||
* PARTICULAR PURPOSE. See the GNU General Public License for more details. *
|
* 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 *
|
* You should have received a copy of the GNU General Public License along with *
|
||||||
* this program. If not, see <http://www.gnu.org/licenses/>. *
|
* this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||||
****************************************************************************************/
|
****************************************************************************************/
|
||||||
|
|
||||||
#include "snarl_backend.h"
|
#include "snarl_backend.h"
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@
|
||||||
#include <QtCore>
|
#include <QtCore>
|
||||||
#include <QTextEdit>
|
#include <QTextEdit>
|
||||||
|
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
|
|
||||||
|
@ -29,96 +30,98 @@
|
||||||
|
|
||||||
Q_EXPORT_PLUGIN2(snarl_backend,Snarl_Backend)
|
Q_EXPORT_PLUGIN2(snarl_backend,Snarl_Backend)
|
||||||
|
|
||||||
Snarl_Backend::Snarl_Backend(SnoreServer *snore):
|
Snarl_Backend::Snarl_Backend(SnoreServer *snore):
|
||||||
Notification_Backend("SnarlBackend",snore)
|
Notification_Backend("SnarlBackend",snore)
|
||||||
{
|
{
|
||||||
Snarl::SnarlInterface *snarlInterface = new Snarl::SnarlInterface();
|
Snarl::SnarlInterface *snarlInterface = new Snarl::SnarlInterface();
|
||||||
_applications.insert("SnoreNotify",snarlInterface);
|
_applications.insert("SnoreNotify",snarlInterface);
|
||||||
qDebug()<<"Initiating Snarl Backend, Snarl version: "<<snarlInterface->GetVersionExA();
|
qDebug()<<"Initiating Snarl Backend, Snarl version: "<<snarlInterface->GetVersionExA();
|
||||||
_defautSnarlinetrface = new Snarl::SnarlInterface();
|
_defautSnarlinetrface = new Snarl::SnarlInterface();
|
||||||
this->installEventFilter(this);
|
this->installEventFilter(this);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Snarl_Backend::~Snarl_Backend(){
|
Snarl_Backend::~Snarl_Backend(){
|
||||||
|
|
||||||
foreach(Application *a,this->snore()->aplications().values()){
|
foreach(Application *a,this->snore()->aplications().values()){
|
||||||
unregisterApplication(a);
|
unregisterApplication(a);
|
||||||
}
|
}
|
||||||
delete _defautSnarlinetrface;
|
delete _defautSnarlinetrface;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Snarl_Backend::registerApplication(Application *application){
|
void Snarl_Backend::registerApplication(Application *application){
|
||||||
Snarl::SnarlInterface *snarlInterface = new Snarl::SnarlInterface();
|
Snarl::SnarlInterface *snarlInterface = new Snarl::SnarlInterface();
|
||||||
_applications.insert(application->name(),snarlInterface);
|
_applications.insert(application->name(),snarlInterface);
|
||||||
|
|
||||||
wchar_t *appName = toWchar(application->name());
|
wchar_t *appName = toWchar(application->name());
|
||||||
wchar_t *icon = toWchar(application->icon());
|
wchar_t *icon = toWchar(application->icon());
|
||||||
snarlInterface->RegisterApp(appName,icon,icon);
|
snarlInterface->RegisterApp(appName,icon,icon);
|
||||||
|
|
||||||
foreach(Alert *alert,application->alerts()){
|
foreach(Alert *alert,application->alerts()){
|
||||||
wchar_t *alertName = toWchar(alert->name());
|
wchar_t *alertName = toWchar(alert->name());
|
||||||
snarlInterface->RegisterAlert(appName,alertName);
|
snarlInterface->RegisterAlert(appName,alertName);
|
||||||
delete [] alertName;
|
delete [] alertName;
|
||||||
}
|
}
|
||||||
delete [] appName;
|
delete [] appName;
|
||||||
delete [] icon;
|
delete [] icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Snarl_Backend::unregisterApplication(Application *application){
|
void Snarl_Backend::unregisterApplication(Application *application){
|
||||||
Snarl::SnarlInterface *snarlInterface = _applications.take(application->name());
|
Snarl::SnarlInterface *snarlInterface = _applications.take(application->name());
|
||||||
if(snarlInterface == NULL)
|
if(snarlInterface == NULL)
|
||||||
return;
|
return;
|
||||||
snarlInterface->UnregisterApp();
|
snarlInterface->UnregisterApp();
|
||||||
delete snarlInterface;
|
delete snarlInterface;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Snarl_Backend::notify(QSharedPointer<Notification>notification){
|
int Snarl_Backend::notify(QSharedPointer<Notification>notification){
|
||||||
Snarl::SnarlInterface *snarlInterface = _applications.value(notification->application());
|
Snarl::SnarlInterface *snarlInterface = _applications.value(notification->application());
|
||||||
if(snarlInterface == NULL)
|
if(snarlInterface == NULL)
|
||||||
snarlInterface = _defautSnarlinetrface;
|
snarlInterface = _defautSnarlinetrface;
|
||||||
|
|
||||||
wchar_t *title = toWchar(Notification::toPlainText(notification->title()));
|
int id = notification->id();
|
||||||
wchar_t *text = toWchar(Notification::toPlainText(notification->text()));
|
wchar_t *title = toWchar(Notification::toPlainText(notification->title()));
|
||||||
wchar_t *icon = toWchar(notification->icon());
|
wchar_t *text = toWchar(Notification::toPlainText(notification->text()));
|
||||||
|
wchar_t *icon = toWchar(notification->icon());
|
||||||
|
|
||||||
if(notification->id()==0){
|
if(notification->id()==0){
|
||||||
wprintf(L"Calling SnarlMessage\n"
|
wprintf(L"Calling SnarlMessage\n"
|
||||||
L"Title: \"%s\"\n"
|
L"Title: \"%s\"\n"
|
||||||
L"Text: \"%s\"\n"
|
L"Text: \"%s\"\n"
|
||||||
L"Timeout: \"%i\"\n"
|
L"Timeout: \"%i\"\n"
|
||||||
L"Icon: \"%s\"\n",title,text,notification->timeout(),icon);
|
L"Icon: \"%s\"\n",title,text,notification->timeout(),icon);
|
||||||
return snarlInterface->ShowMessage(title,text,notification->timeout(), icon);
|
id = snarlInterface->ShowMessage(title,text,notification->timeout(), icon);
|
||||||
}else{
|
}else{
|
||||||
//update message
|
//update message
|
||||||
wprintf(L"Updating SnarlMessage ID: \"%i\"\n"
|
wprintf(L"Updating SnarlMessage ID: \"%i\"\n"
|
||||||
L"Title: \"%s\"\n"
|
L"Title: \"%s\"\n"
|
||||||
L"Text: \"%s\"\n"
|
L"Text: \"%s\"\n"
|
||||||
L"Icon: \"%s\"\n",notification->id(),title,text,icon);
|
L"Icon: \"%s\"\n",notification->id(),title,text,icon);
|
||||||
snarlInterface->UpdateMessage(notification->id(),title, text,icon);
|
snarlInterface->UpdateMessage(notification->id(),title, text,icon);
|
||||||
return notification->id();
|
}
|
||||||
}
|
|
||||||
delete[] title;
|
delete[] title;
|
||||||
delete[] text;
|
delete[] text;
|
||||||
delete[] icon;
|
delete[] icon;
|
||||||
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Snarl_Backend::closeNotification(QSharedPointer<Notification> notification){
|
void Snarl_Backend::closeNotification(QSharedPointer<Notification> notification){
|
||||||
Snarl::SnarlInterface *snarlInterface = _applications.value(notification->application());
|
Snarl::SnarlInterface *snarlInterface = _applications.value(notification->application());
|
||||||
if(snarlInterface == NULL)
|
if(snarlInterface == NULL)
|
||||||
return;
|
return;
|
||||||
snarlInterface->HideMessage(notification->id());
|
snarlInterface->HideMessage(notification->id());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Snarl_Backend::eventFilter(QObject *obj, QEvent *event){
|
bool Snarl_Backend::eventFilter(QObject *obj, QEvent *event){
|
||||||
qDebug()<<obj->objectName();
|
qDebug()<<obj->objectName();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
wchar_t *Snarl_Backend::toWchar(const QString &string){
|
wchar_t *Snarl_Backend::toWchar(const QString &string){
|
||||||
wchar_t *wc = new wchar_t[string.length()+1];
|
wchar_t *wc = new wchar_t[string.length() + 1];
|
||||||
wc[string.toWCharArray(wc)] = 0;
|
wc[string.toWCharArray(wc)] = 0;
|
||||||
return wc;
|
return wc;
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "snarl_backend.moc"
|
#include "snarl_backend.moc"
|
||||||
|
|
Loading…
Reference in New Issue