LeechCraft  0.6.70-10870-g558588d6ec
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 LeechCraft
37 {
38 namespace Util
39 {
40 namespace AN
41 {
42  namespace LAN = LeechCraft::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::CatGeneric, QObject::tr ("Generic") }
55  };
56  return cat2hr;
57  }
58 
59  QStringList GetKnownEventTypes (const QString& category)
60  {
61  static const QMap<QString, QStringList> cat2types
62  {
63  {
64  LAN::CatIM,
65  {
82  }
83  },
84  {
86  {
88  }
89  },
90  {
92  {
95  }
96  },
97  {
99  {
101  }
102  },
103  {
105  {
107  }
108  },
109  {
111  {
115  }
116  },
117  {
119  {
121  }
122  }
123  };
124  return cat2types.value (category);
125  }
126 
127  QString GetCategoryName (const QString& category)
128  {
129  return GetCategoryNameMap ().value (category, category);
130  }
131 
132  QString GetTypeName (const QString& type)
133  {
134  static const QMap<QString, QString> type2hr
135  {
136  { LAN::TypeIMAttention, QObject::tr ("Attention request") },
137  { LAN::TypeIMIncFile, QObject::tr ("Incoming file transfer request") },
138  { LAN::TypeIMIncMsg, QObject::tr ("Incoming chat message") },
139  { LAN::TypeIMMUCHighlight, QObject::tr ("MUC highlight") },
140  { LAN::TypeIMMUCInvite, QObject::tr ("MUC invitation") },
141  { LAN::TypeIMMUCMsg, QObject::tr ("General MUC message") },
142  { LAN::TypeIMStatusChange, QObject::tr ("Contact status change") },
143  { LAN::TypeIMSubscrGrant, QObject::tr ("Authorization granted") },
144  { LAN::TypeIMSubscrRevoke, QObject::tr ("Authorization revoked") },
145  { LAN::TypeIMSubscrRequest, QObject::tr ("Authorization requested") },
146  { LAN::TypeIMSubscrSub, QObject::tr ("Contact subscribed") },
147  { LAN::TypeIMSubscrUnsub, QObject::tr ("Contact unsubscribed") },
148  { LAN::TypeIMEventTuneChange, QObject::tr ("Contact's tune changed") },
149  { LAN::TypeIMEventMoodChange, QObject::tr ("Contact's mood changed") },
150  { LAN::TypeIMEventActivityChange, QObject::tr ("Contact's activity changed") },
151  { LAN::TypeIMEventLocationChange, QObject::tr ("Contact's location changed") },
152 
153  { LAN::TypeOrganizerEventDue, QObject::tr ("Event is due") },
154 
155  { LAN::TypeDownloadError, QObject::tr ("Download error") },
156  { LAN::TypeDownloadFinished, QObject::tr ("Download finished") },
157 
158  { LAN::TypePackageUpdated, QObject::tr ("Package updated") },
159 
160  { LAN::TypeMediaPlaybackStatus, QObject::tr ("Media playback status changed") },
161 
162  { LAN::TypeTerminalBell, QObject::tr ("Bell in a terminal") },
163  { LAN::TypeTerminalActivity, QObject::tr ("Activity in a terminal") },
164  { LAN::TypeTerminalInactivity, QObject::tr ("Inactivity in a terminal") },
165 
166  { LAN::TypeGeneric, QObject::tr ("Generic") }
167  };
168  return type2hr.value (type, type);
169  }
170 }
171 }
172 }
const QString TypeIMMUCHighlight
User has been highlighted in a multiuser chat.
Definition: constants.h:64
const QString TypeGeneric
Generic type for generic notifications.
Definition: constants.h:162
const QString TypeIMIncMsg
User has received a message in a standard one-to-one chat.
Definition: constants.h:56
const QString CatDownloads
Category of Downloads-related events.
Definition: constants.h:117
const QString TypeOrganizerEventDue
An event due date is coming.
Definition: constants.h:113
const QString TypeIMSubscrRevoke
Another user has revoked subscription from our user.
Definition: constants.h:85
const QString TypeIMSubscrRequest
Another user has requested subscription from our user.
Definition: constants.h:88
const QString TypeIMEventTuneChange
User&#39;s tune has changed.
Definition: constants.h:97
const QString TypeIMEventActivityChange
User&#39;s activity has changed.
Definition: constants.h:103
QStringList GetKnownEventTypes(const QString &category)
Returns the known events types for the given category.
Definition: anutil.cpp:59
const QString TypeDownloadError
A download has been failed.
Definition: constants.h:123
const QString TypeIMSubscrGrant
Another user has granted subscription to our user.
Definition: constants.h:82
const QString TypeMediaPlaybackStatus
A media file playback status has been changed.
Definition: constants.h:138
const QString TypeTerminalBell
A bell has ringed in a terminal window.
Definition: constants.h:146
const QString TypeDownloadFinished
A download has been finished successfully without errors.
Definition: constants.h:120
const QString TypeTerminalActivity
Activity in terminal window.
Definition: constants.h:150
QMap< QString, QString > GetCategoryNameMap()
Returns the map from the category ID to its name.
Definition: anutil.cpp:44
const QString CatTerminal
Category for terminal emulation events.
Definition: constants.h:142
const QString TypeIMAttention
Another user has requested our user&#39;s attention.
Definition: constants.h:50
const QString TypeIMSubscrSub
Another user has subscribed to our user.
Definition: constants.h:91
const QString TypeIMEventMoodChange
User&#39;s mood has changed.
Definition: constants.h:100
const QString CatPackageManager
Category of package manager-related events.
Definition: constants.h:127
const QString CatIM
Category of Instant Messaging-related events.
Definition: constants.h:47
const QString TypeIMEventLocationChange
User&#39;s location has changed.
Definition: constants.h:106
const QString TypePackageUpdated
A package has been updated.
Definition: constants.h:130
const QString TypeIMMUCInvite
User has been invited to a multiuser chat.
Definition: constants.h:67
const QString CatOrganizer
Category of Organizer-related events.
Definition: constants.h:110
const QString TypeTerminalInactivity
Inactivity in terminal window.
Definition: constants.h:154
const QString CatMediaPlayer
Category of media player-related events.
Definition: constants.h:134
QString GetCategoryName(const QString &category)
Returns the human-readable name of the event category.
Definition: anutil.cpp:127
const QString TypeIMStatusChange
Another user in our user&#39;s contact list has changed its status.
Definition: constants.h:79
const QString CatGeneric
Generic notifications that don&#39;t fit into any other category.
Definition: constants.h:158
const QString TypeIMIncFile
Another user has sent our user a file.
Definition: constants.h:53
const QString TypeIMMUCMsg
A message has been sent to a multiuser chat.
Definition: constants.h:75
Definition: anutil.h:38
QString GetTypeName(const QString &type)
Returns the human-readable name of the event type.
Definition: anutil.cpp:132
const QString TypeIMSubscrUnsub
Another user has unsubscribed from our user.
Definition: constants.h:94