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 *************************************************************************
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. *
17 *************************************************************************
25 #include <kmessagebox.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 static const QString notifyConnectionLost_DefaultMessage
= i18n("You have been disconnected.");
38 static const QString notifyConnectionLost_DefaultCaption
= i18n("Connection Lost.");
39 static const QString 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.");
41 static const QString notifyCannotConnect_DefaultMessage
= i18n("Cannot connect with the instant messaging server or peers.");
42 static const QString notifyCannotConnect_DefaultCaption
= i18n("Cannot connect.");
43 static const QString 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.");
50 void notify( QPixmap pic
, const QString
&eventid
, const QString
&caption
, const QString
&message
, const QString explanation
, const QString debugInfo
)
55 if ( !explanation
.isEmpty() )
56 actions
<< i18n( "More Information..." );
58 KNotification
*n
= new KNotification( eventid
, 0l );
59 n
->setActions( actions
);
60 n
->setText( message
);
62 ErrorNotificationInfo info
;
63 info
.explanation
= explanation
;
64 info
.debugInfo
= debugInfo
;
66 NotifyHelper::self()->registerNotification(n
, info
);
67 QObject::connect( n
, SIGNAL(activated(unsigned int )) , NotifyHelper::self() , SLOT( slotEventActivated(unsigned int) ) );
68 QObject::connect( n
, SIGNAL(closed()) , NotifyHelper::self() , SLOT( slotEventClosed() ) );
73 void notifyConnectionLost( const Account
*account
, const QString caption
, const QString message
, const QString explanation
, const QString debugInfo
)
78 notify( account
->accountIcon(32), QString::fromLatin1("connection_lost"), caption
.isEmpty() ? notifyConnectionLost_DefaultCaption
: caption
, message
.isEmpty() ? notifyConnectionLost_DefaultMessage
: message
, explanation
.isEmpty() ? notifyConnectionLost_DefaultExplanation
: explanation
, debugInfo
);
81 void notifyCannotConnect( const Account
*account
, const QString explanation
, const QString debugInfo
)
83 Q_UNUSED(explanation
);
88 notify( account
->accountIcon(), QString::fromLatin1("cannot_connect"), notifyCannotConnect_DefaultCaption
, notifyCannotConnect_DefaultMessage
, notifyCannotConnect_DefaultExplanation
, debugInfo
);
91 } // end ns ErrorNotifier