Show invite menu in wlm chat window immediately
[kdenetwork.git] / kopete / libkopete / kopeteutils.cpp
blob6d9e360dcf7f4462c3cc9f822f5cf74a5953b25a
1 /*
2 Kopete Utils.
3 Copyright (c) 2005 Duncan Mac-Vicar Prett <duncan@kde.org>
5 isHostReachable function code derived from KDE's HTTP kioslave
6 Copyright (c) 2005 Waldo Bastian <bastian@kde.org>
8 Kopete (c) 2002-2003 by the Kopete developers <kopete-devel@kde.org>
10 *************************************************************************
11 * *
12 * This library is free software; you can redistribute it and/or *
13 * modify it under the terms of the GNU Lesser General Public *
14 * License as published by the Free Software Foundation; either *
15 * version 2 of the License, or (at your option) any later version. *
16 * *
17 *************************************************************************
20 #include <qmap.h>
21 //Added by qt3to4:
22 #include <QPixmap>
23 #include <QByteArray>
25 #include <kmessagebox.h>
27 #include <klocale.h>
28 #include <kdebug.h>
29 #include <kiconloader.h>
31 #include "kopeteaccount.h"
32 #include "knotification.h"
33 #include "kopeteutils_private.h"
34 #include "kopeteutils.h"
35 #include "kopeteuiglobal.h"
37 namespace Kopete
39 namespace Utils
42 struct DefaultStrings
44 DefaultStrings() :
45 notifyConnectionLost_DefaultMessage(i18n("You have been disconnected.")),
46 notifyConnectionLost_DefaultCaption(i18n("Connection Lost.")),
47 notifyConnectionLost_DefaultExplanation(i18n("Kopete lost the channel used to talk to the instant messaging system.\nThis can be because either your internet access went down, the service is experiencing problems, or the service disconnected you because you tried to connect with the same account from another location. Try connecting again later.")),
49 notifyCannotConnect_DefaultMessage(i18n("Cannot connect with the instant messaging server or peers.")),
50 notifyCannotConnect_DefaultCaption(i18n("Cannot connect.")),
51 notifyCannotConnect_DefaultExplanation(i18n("This means Kopete cannot reach the instant messaging server or peers.\nThis can be because either your internet access is down or the server is experiencing problems. Try connecting again later."))
54 const QString notifyConnectionLost_DefaultMessage;
55 const QString notifyConnectionLost_DefaultCaption;
56 const QString notifyConnectionLost_DefaultExplanation;
58 const QString notifyCannotConnect_DefaultMessage;
59 const QString notifyCannotConnect_DefaultCaption;
60 const QString notifyCannotConnect_DefaultExplanation;
62 K_GLOBAL_STATIC(DefaultStrings, defaultStrings)
64 void notify( QPixmap pic, const QString &eventid, const QString &caption, const QString &message, const QString explanation, const QString debugInfo)
66 Q_UNUSED(caption);
68 QStringList actions;
69 if ( !explanation.isEmpty() )
70 actions << i18n( "More Information..." );
71 kDebug( 14010 ) ;
72 KNotification *n = new KNotification( eventid , 0l );
73 n->setActions( actions );
74 n->setText( message );
75 n->setPixmap( pic );
76 ErrorNotificationInfo info;
77 info.explanation = explanation;
78 info.debugInfo = debugInfo;
80 NotifyHelper::self()->registerNotification(n, info);
81 QObject::connect( n, SIGNAL(activated(unsigned int )) , NotifyHelper::self() , SLOT( slotEventActivated(unsigned int) ) );
82 QObject::connect( n, SIGNAL(closed()) , NotifyHelper::self() , SLOT( slotEventClosed() ) );
84 n->sendEvent();
87 void notifyConnectionLost( const Account *account, const QString caption, const QString message, const QString explanation, const QString debugInfo)
89 if (!account)
90 return;
92 notify( account->accountIcon(32), QString::fromLatin1("connection_lost"), caption.isEmpty() ? defaultStrings->notifyConnectionLost_DefaultCaption : caption, message.isEmpty() ? defaultStrings->notifyConnectionLost_DefaultMessage : message, explanation.isEmpty() ? defaultStrings->notifyConnectionLost_DefaultExplanation : explanation, debugInfo);
95 void notifyCannotConnect( const Account *account, const QString explanation, const QString debugInfo)
97 Q_UNUSED(explanation);
99 if (!account)
100 return;
102 notify( account->accountIcon(), QString::fromLatin1("cannot_connect"), defaultStrings->notifyCannotConnect_DefaultCaption, defaultStrings->notifyCannotConnect_DefaultMessage, defaultStrings->notifyCannotConnect_DefaultExplanation, debugInfo);
105 } // end ns ErrorNotifier
106 } // end ns Kopete