This file is indexed.

/usr/include/licq/userevents.h is in licq-dev 1.8.2-1ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
/*
 * This file is part of Licq, an instant messaging client for UNIX.
 * Copyright (C) 2011-2012 Licq developers <licq-dev@googlegroups.com>
 *
 * Licq is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * Licq is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Licq; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

#ifndef LICQ_USEREVENTS_H
#define LICQ_USEREVENTS_H

#include <cstdlib>
#include <ctime>
#include <list>

#include "color.h"
#include "userid.h"

namespace LicqIcq
{
class IcqProtocol;
}

namespace LicqMsn
{
class CMSN;
}

namespace LicqJabber
{
class Plugin;
}

namespace LicqDaemon
{
class Daemon;
class UserHistory;
}

namespace Licq
{
class User;


//=====CUserEvent===============================================================
class UserEvent
{
public:
  // Define some event flags, leave the 2 LSB's for the licq version
  enum Flags
  {
    FlagLicqVerMask     = 0x0000ffff,
    FlagDirect          = 0x00010000,
    FlagMultiRec        = 0x00020000,
    FlagUrgent          = 0x00040000,
    FlagCancelled       = 0x00080000,
    FlagEncrypted       = 0x00100000,
    FlagSender          = 0x00200000,
    FlagOffline         = 0x00400000,
    FlagUnicode         = 0x00800000,   // Only used in history files for UTF8 encoded messages
    FlagUnknown         = 0x80000000,
  };

  // Event type, for now these must be the same as the ICQ protocol sub commands
  enum EventType
  {
    TypeMessage         = 0x0001,
    TypeChat            = 0x0002,
    TypeFile            = 0x0003,
    TypeUrl             = 0x0004,
    TypeAuthRequest     = 0x0006,
    TypeAuthRefused     = 0x0007,
    TypeAuthGranted     = 0x0008,
    TypeMsgServer       = 0x0009,
    TypeAdded           = 0x000C,
    TypeWebPanel        = 0x000D,
    TypeEmailPager      = 0x000E,
    TypeContactList     = 0x0013,
    TypeSms             = 0x001A,
    TypeEmailAlert      = 0x001C,
    TypeUnknownSys      = 0x001F,
  };

  // Only used for history files, must be same as ICQ protocol commands
  enum HistoryCommand
  {
    CommandDirect       = 0x07EE,
    CommandSent         = 0x010E,
    CommandRcvOnline    = 0x0104,
    CommandRcvOffline   = 0x00DC,
    CommandCancelled    = 0x07D0,
  };

  static const time_t TimeNow = 0;

  /// Return translated event name for an event type
  static std::string eventName(unsigned eventType);

  UserEvent(EventType eventType,
              unsigned short _nSequence, time_t _tTime,
              unsigned long _nFlags, unsigned long _nConvoId = 0);
  UserEvent(const UserEvent *);
  virtual ~UserEvent();

  virtual UserEvent* Copy() const = 0;

  /**
   * Description (including message text) of event
   *
   * @return Text description (in UTF-8)
   */
  const std::string& text() const;

  /**
   * Description (including message text) of event
   *
   * @return Text description (converted to current locale)
   */
  const std::string& textLoc() const;

  std::string description() const;
  time_t Time() const { return m_tTime; }
  const std::string licqVersionStr() const
  { return licqVersionToString(LicqVersion()); }

  static const std::string licqVersionToString(unsigned long);
  unsigned short Sequence() const { return m_nSequence; }

  /// Get type of event
  unsigned eventType() const { return myEventType; }

  /// Returns translated event name
  std::string eventName() const
  { return eventName(eventType()); }

  int Id() const { return m_nId; }
  bool IsDirect() const { return m_nFlags & FlagDirect; }
  bool IsMultiRec() const { return m_nFlags & FlagMultiRec; }
  bool IsUrgent() const { return m_nFlags & FlagUrgent; }
  bool IsCancelled() const { return m_nFlags & FlagCancelled; }
  bool IsLicq() const { return LicqVersion() != 0; };
  bool IsEncrypted() const { return m_nFlags & FlagEncrypted; };
  unsigned short LicqVersion() const { return m_nFlags & FlagLicqVerMask; }

  /// Was message sent from us
  bool isSender() const { return m_nFlags & FlagSender; }

  /// Was message sent while receiver was offline
  bool isOffline() const { return m_nFlags & FlagOffline; }

  bool isReceiver() const { return !isSender(); }
  const Color* color() const { return &myColor; }
  unsigned long ConvoId() const { return m_nConvoId; }

  bool Pending() const { return m_bPending; }
   void SetPending(bool b)  { m_bPending = b; }

protected:
  virtual void AddToHistory(User* user, bool isReceiver) const = 0;

  /**
   * Construct a header for the history entry
   *
   * @param isReceived True if message was received
   * @return String with header data formated for history
   */
  std::string historyHeader(bool isReceiver) const;

  /**
   * Write to user history
   *
   * @param User to write to, must be write locked
   * @param text History entry, including header and formatting
   */
  void writeUserHistory(User* u, const std::string& text) const;

  void Cancel() { m_nFlags |= FlagCancelled; }
  void SetColor(unsigned fore, unsigned back) { myColor.set(fore, back); }
  void SetColor(const Color* c) { myColor.set(c); }

  void CopyBase(const UserEvent* e);

  // CreateDescription() is const even though it changes m_szText since
  // it may be called to perform delayed initialization in const context.
  virtual void CreateDescription() const = 0;
   static int s_nId;

  // m_szText is not initialized until it is accessed. Allow this delayed
  // initialization even if called in const context.
  mutable std::string myText, myTextLoc;
  unsigned myEventType;
   unsigned short m_nSequence;
   int            m_nId;
   time_t         m_tTime;
   unsigned long  m_nFlags;

   bool           m_bPending;
  Color myColor;
   unsigned long  m_nConvoId;

  friend class LicqIcq::IcqProtocol;
  friend class LicqDaemon::Daemon;
  friend class LicqMsn::CMSN;
  friend class LicqJabber::Plugin;
  friend class User;
};


//-----CEventMsg-------------------------------------------------------------
class EventMsg : public UserEvent
{
public:
  EventMsg(const std::string& message,
             time_t _tTime, unsigned long _nFlags, unsigned long _nConvoId = 0);

  virtual EventMsg* Copy() const;
  const std::string& message() const { return myMessage; }
  virtual void AddToHistory(User* u, bool isReceiver) const;

protected:
  void CreateDescription() const;

  std::string myMessage;
};


//-----CEventFile---------------------------------------------------------------
class EventFile : public UserEvent
{
public:
  EventFile(const std::string& filename, const std::string& fileDescription,
      unsigned long _nFileSize, const std::list<std::string>& lFileList,
              unsigned short _nSequence, time_t _tTime,
              unsigned long _nFlags, unsigned long _nConovId = 0,
              unsigned long _nMsgID1 = 0, unsigned long _nMsgID2 = 0);
  virtual EventFile* Copy() const;
  virtual void AddToHistory(User* u, bool isReceiver) const;

  const std::string& filename() const { return myFilename; }
  unsigned long FileSize() const {  return m_nFileSize; }
  const std::string& fileDescription() const { return myFileDescription; }
  const std::list<std::string>& FileList() const { return m_lFileList; }
  const unsigned long* MessageID() const { return m_nMsgID; }
protected:
  void CreateDescription() const;

  std::string myFilename;
  std::string myFileDescription;
   unsigned long m_nFileSize;
  std::list<std::string> m_lFileList;
   unsigned long m_nMsgID[2];
};


//-----CEventUrl----------------------------------------------------------------
class EventUrl : public UserEvent
{
public:
  EventUrl(const std::string& url, const std::string& urlDescription,
      time_t _tTime, unsigned long _nFlags, unsigned long _nConvoId = 0);
  virtual EventUrl* Copy() const;
  virtual void AddToHistory(User* u, bool isReceiver) const;
  const std::string& url() const { return myUrl; }
  const std::string& urlDescription() const { return myUrlDescription; }

protected:
  void CreateDescription() const;

  std::string myUrl;
  std::string myUrlDescription;
};


//-----CEventChat---------------------------------------------------------------
class EventChat : public UserEvent
{
public:
  EventChat(const std::string& reason, unsigned short nSequence, time_t tTime,
      unsigned long nFlags, unsigned long nConvoId = 0, unsigned long nMsgID1 = 0,
      unsigned long nMsgID2 = 0);
  EventChat(const std::string& reason, const std::string& clients, unsigned short nPort,
      unsigned short nSequence, time_t tTime, unsigned long nFlags,
      unsigned long _nConvoId = 0, unsigned long nMsgID1 = 0, unsigned long nMsgID2 = 0);
  virtual EventChat* Copy() const;
  virtual void AddToHistory(User* u, bool isReceiver) const;
  const std::string& reason() const { return myReason; }
  const std::string& clients() const { return myClients; }
  unsigned short Port() const { return m_nPort; }
  const unsigned long* MessageID() const { return m_nMsgID; }
protected:
  void CreateDescription() const;

  std::string myReason;
  std::string myClients;
  unsigned short m_nPort;
  unsigned long m_nMsgID[2];
};


//-----CEventAdded--------------------------------------------------------------
class EventAdded : public UserEvent
{
public:
  EventAdded(const UserId& userId, const std::string& alias,
      const std::string& firstName, const std::string& lastName,
      const std::string& email, time_t _tTime, unsigned long _nFlags);
  virtual EventAdded* Copy() const;
  virtual void AddToHistory(User* u, bool isReceiver) const;
  const UserId& userId() const { return myUserId; }

protected:
  void CreateDescription() const;

  UserId myUserId;
  std::string myAlias;
  std::string myFirstName;
  std::string myLastName;
  std::string myEmail;
};


//-----CEventAuthReq---------------------------------------------------------
class EventAuthRequest : public UserEvent
{
public:
  EventAuthRequest(const UserId& userId, const std::string& alias,
      const std::string& firstName, const std::string& lastName,
      const std::string& email, const std::string& reason,
      time_t _tTime, unsigned long _nFlags);
  virtual EventAuthRequest* Copy() const;
  virtual void AddToHistory(User* u, bool isReceiver) const;
  const UserId& userId() const { return myUserId; }
  const std::string& reason() const { return myReason; }

protected:
  void CreateDescription() const;

  UserId myUserId;
  std::string myAlias;
  std::string myFirstName;
  std::string myLastName;
  std::string myEmail;
  std::string myReason;
};


//-----CEventAuthGranted-------------------------------------------------------
class EventAuthGranted : public UserEvent
{
public:
  EventAuthGranted(const UserId& userId, const std::string& message,
      time_t _tTime, unsigned long _nFlags);
  virtual EventAuthGranted* Copy() const;
  virtual void AddToHistory(User* u, bool isReceiver) const;
  const UserId& userId() const { return myUserId; }
  const std::string& message() const { return myMessage; }

protected:
  void CreateDescription() const;

  UserId myUserId;
  std::string myMessage;
};


//-----CEventAuthRefused------------------------------------------------------
class EventAuthRefused : public UserEvent
{
public:
  EventAuthRefused(const UserId& userId, const std::string& message,
      time_t _tTime, unsigned long _nFlags);
  virtual EventAuthRefused* Copy() const;
  virtual void AddToHistory(User* u, bool isReceiver) const;
  const UserId& userId() const { return myUserId; }
  const std::string& message() const { return myMessage; }

protected:
  void CreateDescription() const;

  UserId myUserId;
  std::string myMessage;
};


//-----CEventWebPanel----------------------------------------------------------
class EventWebPanel : public UserEvent
{
public:
  EventWebPanel(const std::string& name, const std::string& email,
      const std::string& message, time_t _tTime, unsigned long _nFlags);
  virtual EventWebPanel* Copy() const;
  virtual void AddToHistory(User* u, bool isReceiver) const;
  const std::string& message() const { return myMessage; }

protected:
  void CreateDescription() const;

  std::string myName;
  std::string myEmail;
  std::string myMessage;
};


//-----CEventEmailPager----------------------------------------------------------
class EventEmailPager : public UserEvent
{
public:
  EventEmailPager(const std::string& name, const std::string& email,
      const std::string& message, time_t _tTime, unsigned long _nFlags);
  virtual EventEmailPager* Copy() const;
  virtual void AddToHistory(User* u, bool isReceiver) const;
  const std::string& message() const { return myMessage; }

protected:
  void CreateDescription() const;

  std::string myName;
  std::string myEmail;
  std::string myMessage;
};


//-----CEventContactList----------------------------------------------------------
class EventContactList : public UserEvent
{
public:
  class Contact
  {
  public:
    Contact(const UserId& userId, const std::string& alias);

    const UserId& userId() const { return myUserId; }
    const std::string& alias() const { return myAlias; }

  protected:
    UserId myUserId;
    std::string myAlias;
  };
  typedef std::list<Contact *> ContactList;


  EventContactList(const ContactList& cl, bool bDeep,
     time_t tTime, unsigned long nFlags);
  virtual ~EventContactList();
  virtual EventContactList* Copy() const;
  virtual void AddToHistory(User* u, bool isReceiver) const;

  const ContactList &Contacts() const { return m_vszFields; }

protected:
  void CreateDescription() const;

  ContactList m_vszFields;
};


//-----CEventSms---------------------------------------------------------------
class EventSms : public UserEvent
{
public:
  EventSms(const std::string& number, const std::string& message,
      time_t _tTime, unsigned long _nFlags);
  virtual EventSms* Copy() const;
  const std::string& number() const { return myNumber; }
  const std::string& message() const { return myMessage; }
  virtual void AddToHistory(User* u, bool isReceiver) const;

protected:
  void CreateDescription() const;

  std::string myNumber;
  std::string myMessage;
};

//-----CEventServerMessage-----------------------------------------------------
class EventServerMessage : public UserEvent
{
public:
  EventServerMessage(const std::string& name, const std::string& email,
      const std::string& message, time_t _tTime);
  virtual EventServerMessage* Copy() const;
  const std::string& message() const { return myMessage; }
  virtual void AddToHistory(User* u, bool isReceiver) const;

protected:
 void CreateDescription() const;

  std::string myName;
  std::string myEmail;
  std::string myMessage;
};

//-----CEventEmailAlert-----------------------------------------------------
class EventEmailAlert : public UserEvent
{
public:
  EventEmailAlert(const std::string& name, const std::string& email,
      const std::string& to, const std::string& subject, time_t _tTime,
      const std::string& mspAuth = "", const std::string& sid = "",
      const std::string& kv = "", const std::string& id = "",
      const std::string& postUrl = "", const std::string& msgUrl = "",
      const std::string& creds = "", unsigned long sessionLength = 0);
  virtual EventEmailAlert* Copy() const;
  virtual void AddToHistory(User* u, bool isReceiver) const;

  const std::string& from() const { return myName; }
  const std::string& to() const { return myTo; }
  const std::string& email() const { return myEmail; }
  const std::string& subject() const { return mySubject; }

  const std::string& mspAuth() const { return myMspAuth; }
  const std::string& sid() const { return mySid; }
  const std::string& kv() const { return myKv; }
  const std::string& id() const { return myId; }
  const std::string& postUrl() const { return myPostUrl; }
  const std::string& msgUrl() const { return myMsgUrl; }
  const std::string& creds() const { return myCreds; }
  unsigned long sessionLength() const { return mySessionLength; }

protected:
  void CreateDescription() const;

  // Info
  std::string myName;
  std::string myTo;
  std::string myEmail;
  std::string mySubject;

  // For Licq to view an MSN email
  std::string myMspAuth;
  std::string mySid;
  std::string myKv;
  std::string myId;
  std::string myPostUrl;
  std::string myMsgUrl;
  std::string myCreds;
  unsigned long mySessionLength;
};

//-----CEventUnknownSysMsg-----------------------------------------------------
class EventUnknownSysMsg : public UserEvent
{
public:
  EventUnknownSysMsg(unsigned short _nSubCommand, unsigned short _nCommand,
      const UserId& userId, const std::string& message, time_t _tTime, unsigned long _nFlags);
  virtual EventUnknownSysMsg* Copy() const;
  virtual void AddToHistory(User* u, bool isReceiver) const;
  unsigned short subCommand() const { return m_nSubCommand; }
  unsigned short Command() const { return m_nCommand; }

protected:
  void CreateDescription() const;

  unsigned short m_nCommand;
  unsigned short m_nSubCommand;
  UserId myUserId;
  std::string myMessage;
};

} // namespace Licq

#endif