LeechCraft  0.6.70-15082-g543737046d
Modular cross-platform feature rich live environment.
anutil.cpp
Go to the documentation of this file.
1 /**********************************************************************
2  * LeechCraft - modular cross-platform feature rich internet client.
3  * Copyright (C) 2006-2014 Georg Rudoy
4  *
5  * Distributed under the Boost Software License, Version 1.0.
6  * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7  **********************************************************************/
8 
9 #include "anutil.h"
10 #include <QString>
11 #include <QObject>
12 #include <QMap>
14 
15 namespace LC::Util::AN
16 {
17  namespace LAN = LC::AN;
18 
20  {
21  static const QMap<QString, QString> cat2hr
22  {
23  { LAN::CatIM, QObject::tr ("Instant messaging") },
24  { LAN::CatOrganizer, QObject::tr ("Organizer") },
25  { LAN::CatDownloads, QObject::tr ("Downloads") },
26  { LAN::CatPackageManager, QObject::tr ("Package manager") },
27  { LAN::CatMediaPlayer, QObject::tr ("Media player") },
28  { LAN::CatTerminal, QObject::tr ("Terminal") },
29  { LAN::CatNews, QObject::tr ("News") },
30  { LAN::CatGeneric, QObject::tr ("Generic") }
31  };
32  return cat2hr;
33  }
34 
35  QStringList GetKnownEventTypes (const QString& category)
36  {
37  static const QMap<QString, QStringList> cat2types
38  {
39  {
40  LAN::CatIM,
41  {
58  }
59  },
60  {
62  {
64  }
65  },
66  {
68  {
71  }
72  },
73  {
75  {
77  }
78  },
79  {
81  {
83  }
84  },
85  {
87  {
91  }
92  },
93  {
95  {
98  }
99  },
100  {
102  {
104  }
105  }
106  };
107  return cat2types.value (category);
108  }
109 
110  QString GetCategoryName (const QString& category)
111  {
112  return GetCategoryNameMap ().value (category, category);
113  }
114 
115  QString GetTypeName (const QString& type)
116  {
117  static const QMap<QString, QString> type2hr
118  {
119  { LAN::TypeIMAttention, QObject::tr ("Attention request") },
120  { LAN::TypeIMIncFile, QObject::tr ("Incoming file transfer request") },
121  { LAN::TypeIMIncMsg, QObject::tr ("Incoming chat message") },
122  { LAN::TypeIMMUCHighlight, QObject::tr ("MUC highlight") },
123  { LAN::TypeIMMUCInvite, QObject::tr ("MUC invitation") },
124  { LAN::TypeIMMUCMsg, QObject::tr ("General MUC message") },
125  { LAN::TypeIMStatusChange, QObject::tr ("Contact status change") },
126  { LAN::TypeIMSubscrGrant, QObject::tr ("Authorization granted") },
127  { LAN::TypeIMSubscrRevoke, QObject::tr ("Authorization revoked") },
128  { LAN::TypeIMSubscrRequest, QObject::tr ("Authorization requested") },
129  { LAN::TypeIMSubscrSub, QObject::tr ("Contact subscribed") },
130  { LAN::TypeIMSubscrUnsub, QObject::tr ("Contact unsubscribed") },
131  { LAN::TypeIMEventTuneChange, QObject::tr ("Contact's tune changed") },
132  { LAN::TypeIMEventMoodChange, QObject::tr ("Contact's mood changed") },
133  { LAN::TypeIMEventActivityChange, QObject::tr ("Contact's activity changed") },
134  { LAN::TypeIMEventLocationChange, QObject::tr ("Contact's location changed") },
135 
136  { LAN::TypeOrganizerEventDue, QObject::tr ("Event is due") },
137 
138  { LAN::TypeDownloadError, QObject::tr ("Download error") },
139  { LAN::TypeDownloadFinished, QObject::tr ("Download finished") },
140 
141  { LAN::TypePackageUpdated, QObject::tr ("Package updated") },
142 
143  { LAN::TypeMediaPlaybackStatus, QObject::tr ("Media playback status changed") },
144 
145  { LAN::TypeTerminalBell, QObject::tr ("Bell in a terminal") },
146  { LAN::TypeTerminalActivity, QObject::tr ("Activity in a terminal") },
147  { LAN::TypeTerminalInactivity, QObject::tr ("Inactivity in a terminal") },
148 
149  { LAN::TypeNewsSourceUpdated, QObject::tr ("News source got updated") },
150  { LAN::TypeNewsSourceBroken, QObject::tr ("News source is detected to be broken") },
151 
152  { LAN::TypeGeneric, QObject::tr ("Generic") }
153  };
154  return type2hr.value (type, type);
155  }
156 }
LC::AN::TypeIMEventMoodChange
const Q_DECL_IMPORT QString TypeIMEventMoodChange
User's mood has changed.
Definition: anconstantsdefs.cpp:51
LC::AN::TypeTerminalActivity
const Q_DECL_IMPORT QString TypeTerminalActivity
Activity in terminal window.
Definition: anconstantsdefs.cpp:75
LC::AN::TypeIMEventLocationChange
const Q_DECL_IMPORT QString TypeIMEventLocationChange
User's location has changed.
Definition: anconstantsdefs.cpp:53
LC::AN::TypeIMSubscrGrant
const Q_DECL_IMPORT QString TypeIMSubscrGrant
Another user has granted subscription to our user.
Definition: anconstantsdefs.cpp:45
LC::AN::TypeIMSubscrUnsub
const Q_DECL_IMPORT QString TypeIMSubscrUnsub
Another user has unsubscribed from our user.
Definition: anconstantsdefs.cpp:49
LC::AN::CatDownloads
const Q_DECL_IMPORT QString CatDownloads
Category of Downloads-related events.
Definition: anconstantsdefs.cpp:60
LC::AN::TypeOrganizerEventDue
const Q_DECL_IMPORT QString TypeOrganizerEventDue
An event due date is coming.
Definition: anconstantsdefs.cpp:57
LC::AN::TypeGeneric
const Q_DECL_IMPORT QString TypeGeneric
Generic type for generic notifications.
Definition: anconstantsdefs.cpp:85
LC::AN::CatOrganizer
const Q_DECL_IMPORT QString CatOrganizer
Category of Organizer-related events.
Definition: anconstantsdefs.cpp:56
anutil.h
LC::AN::TypeTerminalBell
const Q_DECL_IMPORT QString TypeTerminalBell
A bell has ringed in a terminal window.
Definition: anconstantsdefs.cpp:74
LC::AN::CatIM
const Q_DECL_IMPORT QString CatIM
Category of Instant Messaging-related events.
Definition: anconstantsdefs.cpp:37
LC::AN::TypeIMSubscrSub
const Q_DECL_IMPORT QString TypeIMSubscrSub
Another user has subscribed to our user.
Definition: anconstantsdefs.cpp:48
LC::AN
Definition: constants.h:14
LC::AN::TypeIMMUCInvite
const Q_DECL_IMPORT QString TypeIMMUCInvite
User has been invited to a multiuser chat.
Definition: anconstantsdefs.cpp:42
LC::AN::TypeTerminalInactivity
const Q_DECL_IMPORT QString TypeTerminalInactivity
Inactivity in terminal window.
Definition: anconstantsdefs.cpp:76
LC::AN::TypeNewsSourceBroken
const Q_DECL_IMPORT QString TypeNewsSourceBroken
News source is detected to be broken.
Definition: anconstantsdefs.cpp:81
LC::AN::CatNews
const Q_DECL_IMPORT QString CatNews
Category for news-related events.
Definition: anconstantsdefs.cpp:79
LC::AN::TypeDownloadFinished
const Q_DECL_IMPORT QString TypeDownloadFinished
A download has been finished successfully without errors.
Definition: anconstantsdefs.cpp:61
LC::Util::AN::GetKnownEventTypes
QStringList GetKnownEventTypes(const QString &category)
Returns the known events types for the given category.
Definition: anutil.cpp:41
LC::AN::TypeNewsSourceUpdated
const Q_DECL_IMPORT QString TypeNewsSourceUpdated
News source got updated.
Definition: anconstantsdefs.cpp:80
LC::Util::AN::GetCategoryNameMap
QMap< QString, QString > GetCategoryNameMap()
Returns the map from the category ID to its name.
Definition: anutil.cpp:25
LC::AN::TypeIMEventTuneChange
const Q_DECL_IMPORT QString TypeIMEventTuneChange
User's tune has changed.
Definition: anconstantsdefs.cpp:50
LC::AN::TypeIMIncFile
const Q_DECL_IMPORT QString TypeIMIncFile
Another user has sent our user a file.
Definition: anconstantsdefs.cpp:39
LC::AN::TypeIMStatusChange
const Q_DECL_IMPORT QString TypeIMStatusChange
Another user in our user's contact list has changed its status.
Definition: anconstantsdefs.cpp:44
LC::AN::TypeIMMUCMsg
const Q_DECL_IMPORT QString TypeIMMUCMsg
A message has been sent to a multiuser chat.
Definition: anconstantsdefs.cpp:43
LC::AN::CatMediaPlayer
const Q_DECL_IMPORT QString CatMediaPlayer
Category of media player-related events.
Definition: anconstantsdefs.cpp:69
constants.h
LC::AN::CatGeneric
const Q_DECL_IMPORT QString CatGeneric
Generic notifications that don't fit into any other category.
Definition: anconstantsdefs.cpp:84
LC::Util::AN
Definition: anutil.cpp:15
LC::AN::TypeIMAttention
const Q_DECL_IMPORT QString TypeIMAttention
Another user has requested our user's attention.
Definition: anconstantsdefs.cpp:38
LC::Util::AN::GetCategoryName
QString GetCategoryName(const QString &category)
Returns the human-readable name of the event category.
Definition: anutil.cpp:116
QMap
Definition: anutil.h:17
LC::AN::TypeMediaPlaybackStatus
const Q_DECL_IMPORT QString TypeMediaPlaybackStatus
A media file playback status has been changed.
Definition: anconstantsdefs.cpp:70
LC::AN::TypeDownloadError
const Q_DECL_IMPORT QString TypeDownloadError
A download has been failed.
Definition: anconstantsdefs.cpp:62
LC::AN::TypePackageUpdated
const Q_DECL_IMPORT QString TypePackageUpdated
A package has been updated.
Definition: anconstantsdefs.cpp:66
LC::AN::CatPackageManager
const Q_DECL_IMPORT QString CatPackageManager
Category of package manager-related events.
Definition: anconstantsdefs.cpp:65
LC::AN::TypeIMSubscrRequest
const Q_DECL_IMPORT QString TypeIMSubscrRequest
Another user has requested subscription from our user.
Definition: anconstantsdefs.cpp:47
LC::AN::TypeIMIncMsg
const Q_DECL_IMPORT QString TypeIMIncMsg
User has received a message in a standard one-to-one chat.
Definition: anconstantsdefs.cpp:40
LC::AN::TypeIMEventActivityChange
const Q_DECL_IMPORT QString TypeIMEventActivityChange
User's activity has changed.
Definition: anconstantsdefs.cpp:52
LC::Util::AN::GetTypeName
QString GetTypeName(const QString &type)
Returns the human-readable name of the event type.
Definition: anutil.cpp:121
LC::AN::TypeIMMUCHighlight
const Q_DECL_IMPORT QString TypeIMMUCHighlight
User has been highlighted in a multiuser chat.
Definition: anconstantsdefs.cpp:41
LC::AN::TypeIMSubscrRevoke
const Q_DECL_IMPORT QString TypeIMSubscrRevoke
Another user has revoked subscription from our user.
Definition: anconstantsdefs.cpp:46
LC::AN::CatTerminal
const Q_DECL_IMPORT QString CatTerminal
Category for terminal emulation events.
Definition: anconstantsdefs.cpp:73