• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdenetwork API Reference
  • KDE Home
  • Contact Us
 

kopete/libkopete

  • sources
  • kde-4.12
  • kdenetwork
  • kopete
  • libkopete
kopeteutils.cpp
Go to the documentation of this file.
1 /*
2  Kopete Utils.
3  Copyright (c) 2005 Duncan Mac-Vicar Prett <duncan@kde.org>
4 
5  isHostReachable function code derived from KDE's HTTP kioslave
6  Copyright (c) 2005 Waldo Bastian <bastian@kde.org>
7 
8  Kopete (c) 2002-2003 by the Kopete developers <kopete-devel@kde.org>
9 
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  *************************************************************************
18 */
19 
20 #include <qmap.h>
21 #include <QPixmap>
22 #include <QByteArray>
23 
24 #include <kmessagebox.h>
25 
26 #include <klocale.h>
27 #include <kdebug.h>
28 #include <kiconloader.h>
29 
30 #include "kopeteaccount.h"
31 #include "knotification.h"
32 #include "kopeteutils_private.h"
33 #include "kopeteutils.h"
34 #include "kopeteuiglobal.h"
35 #include "kopetestatusmanager.h"
36 
37 namespace Kopete
38 {
39 namespace Utils
40 {
41 
42 struct DefaultStrings
43 {
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.")),
48 
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."))
52  {
53  }
54  const QString notifyConnectionLost_DefaultMessage;
55  const QString notifyConnectionLost_DefaultCaption;
56  const QString notifyConnectionLost_DefaultExplanation;
57 
58  const QString notifyCannotConnect_DefaultMessage;
59  const QString notifyCannotConnect_DefaultCaption;
60  const QString notifyCannotConnect_DefaultExplanation;
61 };
62 K_GLOBAL_STATIC(DefaultStrings, defaultStrings)
63 
64 void notify( QPixmap pic, const QString &eventid, const QString &caption, const QString &message, const QString explanation, const QString debugInfo)
65 {
66  Q_UNUSED(caption);
67 
68  if ( Kopete::StatusManager::self()->globalStatusCategory() == Kopete::OnlineStatusManager::Busy )
69  return;
70 
71  QStringList actions;
72  if ( !explanation.isEmpty() )
73  actions << i18n( "More Information..." );
74  kDebug( 14010 ) ;
75  KNotification *n = new KNotification( eventid , 0l );
76  n->setActions( actions );
77  n->setText( message );
78  n->setPixmap( pic );
79  ErrorNotificationInfo info;
80  info.explanation = explanation;
81  info.debugInfo = debugInfo;
82 
83  NotifyHelper::self()->registerNotification(n, info);
84  QObject::connect( n, SIGNAL(activated(uint)) , NotifyHelper::self() , SLOT(slotEventActivated(uint)) );
85  QObject::connect( n, SIGNAL(closed()) , NotifyHelper::self() , SLOT(slotEventClosed()) );
86 
87  n->sendEvent();
88 }
89 
90 void notifyConnectionLost( const Account *account, const QString caption, const QString message, const QString explanation, const QString debugInfo)
91 {
92  if (!account)
93  return;
94 
95  notify( account->accountIcon(KIconLoader::SizeMedium), QString::fromLatin1("connection_lost"), caption.isEmpty() ? defaultStrings->notifyConnectionLost_DefaultCaption : caption, message.isEmpty() ? defaultStrings->notifyConnectionLost_DefaultMessage : message, explanation.isEmpty() ? defaultStrings->notifyConnectionLost_DefaultExplanation : explanation, debugInfo);
96 }
97 
98 void notifyCannotConnect( const Account *account, const QString explanation, const QString debugInfo)
99 {
100  Q_UNUSED(explanation);
101 
102  if (!account)
103  return;
104 
105  notify( account->accountIcon(KIconLoader::SizeMedium), QString::fromLatin1("cannot_connect"), defaultStrings->notifyCannotConnect_DefaultCaption, defaultStrings->notifyCannotConnect_DefaultMessage, defaultStrings->notifyCannotConnect_DefaultExplanation, debugInfo);
106 }
107 
108 } // end ns ErrorNotifier
109 } // end ns Kopete
110 
kopeteutils.h
kopetestatusmanager.h
Kopete::Utils::ErrorNotificationInfo::debugInfo
QString debugInfo
Definition: kopeteutils_private.h:37
kopeteaccount.h
Kopete::StatusManager::self
static StatusManager * self()
Get the only instance of StatusManager.
Definition: kopetestatusmanager.cpp:145
Kopete::Utils::NotifyHelper::self
static NotifyHelper * self()
Definition: kopeteutils_private.cpp:44
Kopete::Utils::notifyCannotConnect
void notifyCannotConnect(const Account *account, const QString explanation, const QString debugInfo)
Notifies the user the server is not reachable without coupling plugins with GUI code.
Definition: kopeteutils.cpp:98
kopeteuiglobal.h
Kopete::Utils::ErrorNotificationInfo::explanation
QString explanation
Definition: kopeteutils_private.h:36
Kopete::Utils::ErrorNotificationInfo
Definition: kopeteutils_private.h:33
Kopete::Utils::NotifyHelper::registerNotification
void registerNotification(const KNotification *event, ErrorNotificationInfo error)
Definition: kopeteutils_private.cpp:74
Kopete::Account::accountIcon
QPixmap accountIcon
Definition: kopeteaccount.h:80
Kopete::OnlineStatusManager::Busy
Definition: kopeteonlinestatusmanager.h:63
Kopete::Utils::notifyConnectionLost
void notifyConnectionLost(const Account *account, const QString caption, const QString message, const QString explanation, const QString debugInfo)
Notifies the user connection has been lost without coupling plugins with GUI code.
Definition: kopeteutils.cpp:90
Kopete::Utils::notify
void notify(QPixmap pic, const QString &eventid, const QString &caption, const QString &message, const QString explanation, const QString debugInfo)
Definition: kopeteutils.cpp:64
Kopete::Account
The Kopete::Account class handles one account.
Definition: kopeteaccount.h:72
kopeteutils_private.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:53:51 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kopete/libkopete

Skip menu "kopete/libkopete"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdenetwork API Reference

Skip menu "kdenetwork API Reference"
  • kget
  • kopete
  •   kopete
  •   libkopete
  • krdc
  • krfb

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal