[prev in list] [next in list] [prev in thread] [next in thread]
List: kopete-devel
Subject: [Kopete-devel] [PATCH] Sync KopeteNotifyClient?
From: Will Stephenson <william.stephenson () ncl ! ac ! uk>
Date: 2003-11-04 15:20:15
[Download RAW message or body]
Hi all
There have been some changes to knotify in kdelibs since we last updated
KopeteNotifyClient, including an (unnecessary in our case) fix to a crash
bug, one of those WM_FUNNY_FLAGS, and macro expansion in notifyByExecute
calls. At the moment some events use our extended KopeteNotifyClient
methods, whereas others are passed through to KNotifyClient.
I'd like to sync KNC against kdelibs head to include these fixes and restore
consistency.
The event handling and macro expansion is the motivator for this post - I
looked on our forums and saw someone wondering how to add arguments to
byExecute notifications so he could use an On Screen Display, but when I
investigated this I saw that our 'kopete_online' events aren't
macro-expanded. 'kopete_offline' are expanded because they are passed
through to knotifyclient.
'macro expansion in execute' allows us to include the text of the passive
popup, for example, in the command line executed. If you apply the attached
patch and set your buddy goes online notification to execute this
echo %s | osd_cat -o 100 -p bottom -A center -f
-*-helvetica-*-r-*-*-24-*-*-*-*-*-*-* -O 2 -c gold
we easily add Yet Another Notification Method* to our armoury. Requires
libxosd and that font, thanks mETz for reminding me about xfontsel.
Will
*mETz: this looks pretty terrible when you go on line, you were warned!
--
Will Stephenson
IRC: Bille
["kopetenotifyclient.diff" (text/x-diff)]
? libkopete/.kopetenotifyclient.cpp.swp
? libkopete/.kopetenotifyclient.h.swp
Index: libkopete/kopetenotifyclient.cpp
===================================================================
RCS file: /home/kde/kdenetwork/kopete/libkopete/kopetenotifyclient.cpp,v
retrieving revision 1.4
diff -u -1 -b -p -r1.4 kopetenotifyclient.cpp
--- libkopete/kopetenotifyclient.cpp 25 Oct 2003 23:07:27 -0000 1.4
+++ libkopete/kopetenotifyclient.cpp 4 Nov 2003 15:19:31 -0000
@@ -35,2 +35,3 @@
#include <klocale.h>
+#include <kmacroexpander.h>
#include <kmessagebox.h>
@@ -78,3 +79,4 @@ static int notifyBySound( const QString
-static bool notifyByMessagebox(const QString &text, int level, const KGuiItem \
&action , QObject* receiver , const char* slot) +static bool notifyByMessagebox(const \
QString &text, int level, WId winId, const KGuiItem &action, + QObject* receiver , \
const char* slot) {
@@ -89,12 +91,12 @@ static bool notifyByMessagebox(const QSt
case KNotifyClient::Notification:
- KMessageBox::information( 0, text, i18n( "Notification" ) );
+ KMessageBox::informationWId( winId, text, i18n( "Notification" ) );
break;
case KNotifyClient::Warning:
- KMessageBox::sorry( 0, text, i18n( "Warning" ) );
+ KMessageBox::sorryWId( winId, text, i18n( "Warning" ) );
break;
case KNotifyClient::Error:
- KMessageBox::error( 0, text, i18n( "Error" ) );
+ KMessageBox::errorWId( winId, text, i18n( "Error" ) );
break;
case KNotifyClient::Catastrophe:
- KMessageBox::error( 0, text, i18n( "Fatal" ) );
+ KMessageBox::errorWId( winId, text, i18n( "Fatal" ) );
break;
@@ -161,8 +163,19 @@ static bool notifyByPassivePopup( const
-static bool notifyByExecute(const QString &command) {
+static bool notifyByExecute( const QString &command, const QString& event,
+ const QString& fromApp, const QString& text,
+ int winId, int eventId ) {
if (!command.isEmpty()) {
// kdDebug() << "executing command '" << command << "'" << endl;
+ QMap<QChar,QString> subst;
+ subst.insert( 'e', event );
+ subst.insert( 'a', fromApp );
+ subst.insert( 's', text );
+ subst.insert( 'w', QString::number( winId ) );
+ subst.insert( 'i', QString::number( eventId ) );
+ QString execLine = KMacroExpander::expandMacrosShellQuote( command, subst );
+ if ( execLine.isEmpty() )
+ execLine = command; // fallback
KProcess p;
p.setUseShell(true);
- p << command;
+ p << execLine;
p.start(KProcess::DontCare);
@@ -286,5 +299,7 @@ int KNotifyClient::event(int winId, cons
if( present & KNotifyClient::Sound ) {
- sound = configFile.readPathEntry( "soundfile" );
- if ( sound.length()==0 )
- sound = eventsFile.readPathEntry( "default_sound" );
+ QString theSound = configFile.readPathEntry( "soundfile" );
+ if ( theSound.isEmpty() )
+ theSound = eventsFile.readPathEntry( "default_sound" );
+ if ( !theSound.isEmpty() )
+ sound = theSound;
}
@@ -293,5 +308,7 @@ int KNotifyClient::event(int winId, cons
if( present & KNotifyClient::Logfile ) {
- file = configFile.readPathEntry( "logfile" );
- if ( file.length()==0 )
- file = eventsFile.readPathEntry( "default_logfile" );
+ QString theFile = configFile.readPathEntry( "logfile" );
+ if ( theFile.isEmpty() )
+ theFile = eventsFile.readPathEntry( "default_logfile" );
+ if ( !theFile.isEmpty() )
+ file = theFile;
}
@@ -305,3 +322,3 @@ int KNotifyClient::event(int winId, cons
commandline = configFile.readPathEntry( "commandline" );
- if ( commandline.length()==0 )
+ if ( commandline.isEmpty() )
commandline = eventsFile.readPathEntry( "default_commandline" );
@@ -310,7 +327,8 @@ int KNotifyClient::event(int winId, cons
- return userEvent(winId, text, present , level, sound, file, commandline, \
action, receiver, slot); + return userEvent(winId, message, text, present , \
level, sound, file, commandline, action, receiver, + slot);
}
-int KNotifyClient::userEvent(int winId, const QString &text, int present, int level,
- const QString &sound, const QString &file, const \
QString& commandline, +int KNotifyClient::userEvent(int winId, const QString \
&message, const QString &text, int present, + int level, const QString &sound, const \
QString &file, const QString& commandline,
const KGuiItem &action , QObject* receiver , const \
char* slot) @@ -334,3 +352,3 @@ int KNotifyClient::userEvent(int winId,
else if ( present & KNotifyClient::Messagebox )
- notifyByMessagebox( text, level, action, receiver, slot );
+ notifyByMessagebox( text, level, winId, action, receiver, slot );
@@ -343,3 +361,3 @@ int KNotifyClient::userEvent(int winId,
if ( present & KNotifyClient::Execute )
- notifyByExecute( commandline );
+ notifyByExecute( commandline, message, appname, text, winId, uniqueId );
Index: libkopete/kopetenotifyclient.h
===================================================================
RCS file: /home/kde/kdenetwork/kopete/libkopete/kopetenotifyclient.h,v
retrieving revision 1.3
diff -u -1 -b -p -r1.3 kopetenotifyclient.h
--- libkopete/kopetenotifyclient.h 7 Sep 2003 21:36:28 -0000 1.3
+++ libkopete/kopetenotifyclient.h 4 Nov 2003 15:19:31 -0000
@@ -68,4 +68,4 @@ namespace KNotifyClient
*/
- int userEvent(int winId, const QString &text, int present, int level, const QString \
&sound,
- const QString &file, const QString &commandline,
+ int userEvent(int winId, const QString &message, const QString &text, int present, \
int level, + const QString &sound, const QString &file, const QString \
&commandline,
const KGuiItem &action = KGuiItem() , QObject *receiver=0L, const char \
*slot=0L);
_______________________________________________
Kopete-devel mailing list
Kopete-devel@kde.org
https://mail.kde.org/mailman/listinfo/kopete-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic