LeechCraft  0.6.70-13605-g8cd066ad6a
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  * Boost Software License - Version 1.0 - August 17th, 2003
6  *
7  * Permission is hereby granted, free of charge, to any person or organization
8  * obtaining a copy of the software and accompanying documentation covered by
9  * this license (the "Software") to use, reproduce, display, distribute,
10  * execute, and transmit the Software, and to prepare derivative works of the
11  * Software, and to permit third-parties to whom the Software is furnished to
12  * do so, all subject to the following:
13  *
14  * The copyright notices in the Software and this entire statement, including
15  * the above license grant, this restriction and the following disclaimer,
16  * must be included in all copies of the Software, in whole or in part, and
17  * all derivative works of the Software, unless such copies or derivative
18  * works are solely in the form of machine-executable object code generated by
19  * a source language processor.
20  *
21  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23  * FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
24  * SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
25  * FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
26  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27  * DEALINGS IN THE SOFTWARE.
28  **********************************************************************/
29 
30 #include "anutil.h"
31 #include <QString>
32 #include <QObject>
33 #include <QMap>
35 
36 namespace LC
37 {
38 namespace Util
39 {
40 namespace AN
41 {
42  namespace LAN = LC::AN;
43 
45  {
46  static const QMap<QString, QString> cat2hr
47  {
48  { LAN::CatIM, QObject::tr ("Instant messaging") },
49  { LAN::CatOrganizer, QObject::tr ("Organizer") },
50  { LAN::CatDownloads, QObject::tr ("Downloads") },
51  { LAN::CatPackageManager, QObject::tr ("Package manager") },
52  { LAN::CatMediaPlayer, QObject::tr ("Media player") },
53  { LAN::CatTerminal, QObject::tr ("Terminal") },
54  { LAN::CatNews, QObject::tr ("News") },
55  { LAN::CatGeneric, QObject::tr ("Generic") }
56  };
57  return cat2hr;
58  }
59 
60  QStringList GetKnownEventTypes (const QString& category)
61  {
62  static const QMap<QString, QStringList> cat2types
63  {
64  {
65  LAN::CatIM,
66  {
83  }
84  },
85  {
87  {
89  }
90  },
91  {
93  {
96  }
97  },
98  {
100  {
102  }
103  },
104  {
106  {
108  }
109  },
110  {
112  {
116  }
117  },
118  {
119  LAN::CatNews,
120  {
123  }
124  },
125  {
127  {
129  }
130  }
131  };
132  return cat2types.value (category);
133  }
134 
135  QString GetCategoryName (const QString& category)
136  {
137  return GetCategoryNameMap ().value (category, category);
138  }
139 
140  QString GetTypeName (const QString& type)
141  {
142  static const QMap<QString, QString> type2hr
143  {
144  { LAN::TypeIMAttention, QObject::tr ("Attention request") },
145  { LAN::TypeIMIncFile, QObject::tr ("Incoming file transfer request") },
146  { LAN::TypeIMIncMsg, QObject::tr ("Incoming chat message") },
147  { LAN::TypeIMMUCHighlight, QObject::tr ("MUC highlight") },
148  { LAN::TypeIMMUCInvite, QObject::tr ("MUC invitation") },
149  { LAN::TypeIMMUCMsg, QObject::tr ("General MUC message") },
150  { LAN::TypeIMStatusChange, QObject::tr ("Contact status change") },
151  { LAN::TypeIMSubscrGrant, QObject::tr ("Authorization granted") },
152  { LAN::TypeIMSubscrRevoke, QObject::tr ("Authorization revoked") },
153  { LAN::TypeIMSubscrRequest, QObject::tr ("Authorization requested") },
154  { LAN::TypeIMSubscrSub, QObject::tr ("Contact subscribed") },
155  { LAN::TypeIMSubscrUnsub, QObject::tr ("Contact unsubscribed") },
156  { LAN::TypeIMEventTuneChange, QObject::tr ("Contact's tune changed") },
157  { LAN::TypeIMEventMoodChange, QObject::tr ("Contact's mood changed") },
158  { LAN::TypeIMEventActivityChange, QObject::tr ("Contact's activity changed") },
159  { LAN::TypeIMEventLocationChange, QObject::tr ("Contact's location changed") },
160 
161  { LAN::TypeOrganizerEventDue, QObject::tr ("Event is due") },
162 
163  { LAN::TypeDownloadError, QObject::tr ("Download error") },
164  { LAN::TypeDownloadFinished, QObject::tr ("Download finished") },
165 
166  { LAN::TypePackageUpdated, QObject::tr ("Package updated") },
167 
168  { LAN::TypeMediaPlaybackStatus, QObject::tr ("Media playback status changed") },
169 
170  { LAN::TypeTerminalBell, QObject::tr ("Bell in a terminal") },
171  { LAN::TypeTerminalActivity, QObject::tr ("Activity in a terminal") },
172  { LAN::TypeTerminalInactivity, QObject::tr ("Inactivity in a terminal") },
173 
174  { LAN::TypeNewsSourceUpdated, QObject::tr ("News source got updated") },
175  { LAN::TypeNewsSourceBroken, QObject::tr ("News source is detected to be broken") },
176 
177  { LAN::TypeGeneric, QObject::tr ("Generic") }
178  };
179  return type2hr.value (type, type);
180  }
181 }
182 }
183 }
LC::AN::TypeIMEventMoodChange
const Q_DECL_IMPORT QString TypeIMEventMoodChange
User's mood has changed.
Definition: anconstantsdefs.cpp:78
LC::AN::TypeTerminalActivity
const Q_DECL_IMPORT QString TypeTerminalActivity
Activity in terminal window.
Definition: anconstantsdefs.cpp:97
LC::AN::TypeIMEventLocationChange
const Q_DECL_IMPORT QString TypeIMEventLocationChange
User's location has changed.
Definition: anconstantsdefs.cpp:80
LC::AN::TypeIMSubscrGrant
const Q_DECL_IMPORT QString TypeIMSubscrGrant
Another user has granted subscription to our user.
Definition: anconstantsdefs.cpp:72
LC::AN::TypeIMSubscrUnsub
const Q_DECL_IMPORT QString TypeIMSubscrUnsub
Another user has unsubscribed from our user.
Definition: anconstantsdefs.cpp:76
LC::AN::CatDownloads
const Q_DECL_IMPORT QString CatDownloads
Category of Downloads-related events.
Definition: anconstantsdefs.cpp:85
LC::AN::TypeOrganizerEventDue
const Q_DECL_IMPORT QString TypeOrganizerEventDue
An event due date is coming.
Definition: anconstantsdefs.cpp:83
LC::AN::TypeGeneric
const Q_DECL_IMPORT QString TypeGeneric
Generic type for generic notifications.
Definition: anconstantsdefs.cpp:105
LC::AN::CatOrganizer
const Q_DECL_IMPORT QString CatOrganizer
Category of Organizer-related events.
Definition: anconstantsdefs.cpp:82
anutil.h
LC::AN::TypeTerminalBell
const Q_DECL_IMPORT QString TypeTerminalBell
A bell has ringed in a terminal window.
Definition: anconstantsdefs.cpp:96
LC::AN::CatIM
const Q_DECL_IMPORT QString CatIM
Category of Instant Messaging-related events.
Definition: anconstantsdefs.cpp:64
LC::AN::TypeIMSubscrSub
const Q_DECL_IMPORT QString TypeIMSubscrSub
Another user has subscribed to our user.
Definition: anconstantsdefs.cpp:75
LC::AN
Definition: constants.h:62
LC::AN::TypeIMMUCInvite
const Q_DECL_IMPORT QString TypeIMMUCInvite
User has been invited to a multiuser chat.
Definition: anconstantsdefs.cpp:69
LC::AN::TypeTerminalInactivity
const Q_DECL_IMPORT QString TypeTerminalInactivity
Inactivity in terminal window.
Definition: anconstantsdefs.cpp:98
LC::AN::TypeNewsSourceBroken
const Q_DECL_IMPORT QString TypeNewsSourceBroken
News source is detected to be broken.
Definition: anconstantsdefs.cpp:102
LC::AN::CatNews
const Q_DECL_IMPORT QString CatNews
Category for news-related events.
Definition: anconstantsdefs.cpp:100
LC::AN::TypeDownloadFinished
const Q_DECL_IMPORT QString TypeDownloadFinished
A download has been finished successfully without errors.
Definition: anconstantsdefs.cpp:86
LC::Util::AN::GetKnownEventTypes
QStringList GetKnownEventTypes(const QString &category)
Returns the known events types for the given category.
Definition: anutil.cpp:138
LC::AN::TypeNewsSourceUpdated
const Q_DECL_IMPORT QString TypeNewsSourceUpdated
News source got updated.
Definition: anconstantsdefs.cpp:101
LC::Util::AN::GetCategoryNameMap
QMap< QString, QString > GetCategoryNameMap()
Returns the map from the category ID to its name.
Definition: anutil.cpp:122
LC::AN::TypeIMEventTuneChange
const Q_DECL_IMPORT QString TypeIMEventTuneChange
User's tune has changed.
Definition: anconstantsdefs.cpp:77
LC::AN::TypeIMIncFile
const Q_DECL_IMPORT QString TypeIMIncFile
Another user has sent our user a file.
Definition: anconstantsdefs.cpp:66
LC::AN::TypeIMStatusChange
const Q_DECL_IMPORT QString TypeIMStatusChange
Another user in our user's contact list has changed its status.
Definition: anconstantsdefs.cpp:71
LC::AN::TypeIMMUCMsg
const Q_DECL_IMPORT QString TypeIMMUCMsg
A message has been sent to a multiuser chat.
Definition: anconstantsdefs.cpp:70
LC::AN::CatMediaPlayer
const Q_DECL_IMPORT QString CatMediaPlayer
Category of media player-related events.
Definition: anconstantsdefs.cpp:92
LC
Definition: constants.h:34
constants.h
LC::AN::CatGeneric
const Q_DECL_IMPORT QString CatGeneric
Generic notifications that don't fit into any other category.
Definition: anconstantsdefs.cpp:104
LC::AN::TypeIMAttention
const Q_DECL_IMPORT QString TypeIMAttention
Another user has requested our user's attention.
Definition: anconstantsdefs.cpp:65
LC::Util::AN::GetCategoryName
QString GetCategoryName(const QString &category)
Returns the human-readable name of the event category.
Definition: anutil.cpp:213
QMap
Definition: anutil.h:37
LC::AN::TypeMediaPlaybackStatus
const Q_DECL_IMPORT QString TypeMediaPlaybackStatus
A media file playback status has been changed.
Definition: anconstantsdefs.cpp:93
LC::AN::TypeDownloadError
const Q_DECL_IMPORT QString TypeDownloadError
A download has been failed.
Definition: anconstantsdefs.cpp:87
LC::AN::TypePackageUpdated
const Q_DECL_IMPORT QString TypePackageUpdated
A package has been updated.
Definition: anconstantsdefs.cpp:90
LC::AN::CatPackageManager
const Q_DECL_IMPORT QString CatPackageManager
Category of package manager-related events.
Definition: anconstantsdefs.cpp:89
LC::AN::TypeIMSubscrRequest
const Q_DECL_IMPORT QString TypeIMSubscrRequest
Another user has requested subscription from our user.
Definition: anconstantsdefs.cpp:74
LC::AN::TypeIMIncMsg
const Q_DECL_IMPORT QString TypeIMIncMsg
User has received a message in a standard one-to-one chat.
Definition: anconstantsdefs.cpp:67
LC::AN::TypeIMEventActivityChange
const Q_DECL_IMPORT QString TypeIMEventActivityChange
User's activity has changed.
Definition: anconstantsdefs.cpp:79
LC::Util::AN::GetTypeName
QString GetTypeName(const QString &type)
Returns the human-readable name of the event type.
Definition: anutil.cpp:218
LC::AN::TypeIMMUCHighlight
const Q_DECL_IMPORT QString TypeIMMUCHighlight
User has been highlighted in a multiuser chat.
Definition: anconstantsdefs.cpp:68
LC::AN::TypeIMSubscrRevoke
const Q_DECL_IMPORT QString TypeIMSubscrRevoke
Another user has revoked subscription from our user.
Definition: anconstantsdefs.cpp:73
LC::AN::CatTerminal
const Q_DECL_IMPORT QString CatTerminal
Category for terminal emulation events.
Definition: anconstantsdefs.cpp:95