UserLists.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * UserLists.h
  3. * nirc
  4. *
  5. * Created by Niklas Bölter on 27.02.10.
  6. * Copyright 2010 Frubar Corporation.
  7. *
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. *
  15. *
  16. */
  17. #include <QHash>
  18. #include <QStringList>
  19. class UserList : public QObject
  20. {
  21. Q_OBJECT
  22. public:
  23. UserList();
  24. void clearChannel(QString channel);
  25. void addUser(QString channel, QString nickname);
  26. void addUser(QString channel, QString nickname, QHash<QChar, QChar> prefix);
  27. void changeNick(QString channel, QString oldnick, QString newnick);
  28. void removeUser(QString channel, QString nickname);
  29. void addChannel(QString channel);
  30. void removeChannel(QString channel);
  31. QStringList getUsers(QString channel);
  32. QStringList getChannels(QString nickname);
  33. QString getPrivs(QString channel, QString nickname);
  34. void setPrivs(QString channel, QString nickname, QString privs);
  35. bool hasPriv(QString channel, QString nickname, QChar priv);
  36. void addPriv(QString channel, QString nickname, QChar priv);
  37. void removePriv(QString channel, QString nickname, QChar priv);
  38. QChar getPrefix(QString channel, QString nickname);
  39. void setPrefix(QString channel, QString nickname, QChar pref);
  40. private:
  41. QHash<QString, int> channels;
  42. QList<QStringList> nicks;
  43. QList<QStringList> privs;
  44. QList<QList<QChar> > prefix;
  45. int getId(QString channel);
  46. };
  47. class UserLists : public QObject
  48. {
  49. Q_OBJECT
  50. public:
  51. UserLists();
  52. void clearChannel(int cid, QString channel);
  53. void addUser(int cid, QString channel, QString nickname);
  54. void addUser(int cid, QString channel, QString nickname, QHash<QChar, QChar> prefix);
  55. void changeNick(int cid, QString channel, QString oldnick, QString newnick);
  56. void removeUser(int cid, QString channel, QString nickname);
  57. void removeChannel(int cid, QString channel);
  58. void addChannel(int cid, QString channel);
  59. QStringList getUsers(int cid, QString channel);
  60. QStringList getChannels(int cid, QString nickname);
  61. QString getPrivs(int cid, QString channel, QString nickname);
  62. void setPrivs(int cid, QString channel, QString nickname, QString privs);
  63. bool hasPriv(int cid, QString channel, QString nickname, QChar priv);
  64. void addPriv(int cid, QString channel, QString nickname, QChar priv);
  65. void removePriv(int cid, QString channel, QString nickname, QChar priv);
  66. QChar getPrefix(int cid, QString channel, QString nickname);
  67. void setPrefix(int cid, QString channel, QString nickname, QChar pref);
  68. private:
  69. QList<UserList *> lists;
  70. UserList * getList(int cid);
  71. };