• 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.14
  • 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 "kopeteutils.h"
21 
22 #include <qmap.h>
23 #include <QPixmap>
24 #include <QByteArray>
25 
26 #include <kmessagebox.h>
27 
28 #include <klocale.h>
29 #include <kdebug.h>
30 #include <kiconloader.h>
31 
32 #include "kopeteaccount.h"
33 #include "knotification.h"
34 #include "kopeteutils_private.h"
35 #include "kopeteuiglobal.h"
36 #include "kopetestatusmanager.h"
37 
38 namespace Kopete
39 {
40 namespace Utils
41 {
42 
43 struct DefaultStrings
44 {
45  DefaultStrings() :
46  notifyConnectionLost_DefaultMessage(i18n("You have been disconnected.")),
47  notifyConnectionLost_DefaultCaption(i18n("Connection Lost.")),
48  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 
50  notifyCannotConnect_DefaultMessage(i18n("Cannot connect with the instant messaging server or peers.")),
51  notifyCannotConnect_DefaultCaption(i18n("Cannot connect.")),
52  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."))
53  {
54  }
55  const QString notifyConnectionLost_DefaultMessage;
56  const QString notifyConnectionLost_DefaultCaption;
57  const QString notifyConnectionLost_DefaultExplanation;
58 
59  const QString notifyCannotConnect_DefaultMessage;
60  const QString notifyCannotConnect_DefaultCaption;
61  const QString notifyCannotConnect_DefaultExplanation;
62 };
63 K_GLOBAL_STATIC(DefaultStrings, defaultStrings)
64 
65 void notify( QPixmap pic, const QString &eventid, const QString &caption, const QString &message, const QString explanation, const QString debugInfo)
66 {
67  Q_UNUSED(caption);
68 
69  if ( Kopete::StatusManager::self()->globalStatusCategory() == Kopete::OnlineStatusManager::Busy )
70  return;
71 
72  QStringList actions;
73  if ( !explanation.isEmpty() )
74  actions << i18n( "More Information..." );
75  kDebug( 14010 ) ;
76  KNotification *n = new KNotification( eventid , 0l );
77  n->setActions( actions );
78  n->setText( message );
79  n->setPixmap( pic );
80  ErrorNotificationInfo info;
81  info.explanation = explanation;
82  info.debugInfo = debugInfo;
83 
84  NotifyHelper::self()->registerNotification(n, info);
85  QObject::connect( n, SIGNAL(activated(uint)) , NotifyHelper::self() , SLOT(slotEventActivated(uint)) );
86  QObject::connect( n, SIGNAL(closed()) , NotifyHelper::self() , SLOT(slotEventClosed()) );
87 
88  n->sendEvent();
89 }
90 
91 void notifyConnectionLost( const Account *account, const QString caption, const QString message, const QString explanation, const QString debugInfo)
92 {
93  if (!account)
94  return;
95 
96  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);
97 }
98 
99 void notifyCannotConnect( const Account *account, const QString explanation, const QString debugInfo)
100 {
101  Q_UNUSED(explanation);
102 
103  if (!account)
104  return;
105 
106  notify( account->accountIcon(KIconLoader::SizeMedium), QString::fromLatin1("cannot_connect"), defaultStrings->notifyCannotConnect_DefaultCaption, defaultStrings->notifyCannotConnect_DefaultMessage, defaultStrings->notifyCannotConnect_DefaultExplanation, debugInfo);
107 }
108 
109 } // end ns ErrorNotifier
110 } // end ns Kopete
111 
kopeteutils.h
kopetestatusmanager.h
Kopete::Utils::ErrorNotificationInfo::debugInfo
QString debugInfo
Definition: kopeteutils_private.h:38
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:99
kopeteuiglobal.h
Kopete::Utils::ErrorNotificationInfo::explanation
QString explanation
Definition: kopeteutils_private.h:37
QString::isEmpty
bool isEmpty() const
Kopete::Utils::ErrorNotificationInfo
Definition: kopeteutils_private.h:34
QString
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
QStringList
QPixmap
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:91
QString::fromLatin1
QString fromLatin1(const char *str, int size)
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:65
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
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-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:29:19 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