summaryrefslogtreecommitdiff
path: root/src/social/socialapp.h
blob: 0800b1494cc30b73f8d44c0774da7c8125f1a140 (plain) (blame)
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
#ifndef SOCIAL_APP_H
#define SOCIAL_APP_H

#include <QObject>
#include <QDebug>

#include "social/ego.h"
#include "social/place.h"
#include "gnunet.h"

class SocialApp : public QObject
{
  Q_OBJECT;

 public:

  explicit SocialApp (GNUNET_CONFIGURATION_Handle * config,
                      QObject *parent = 0);
  ~SocialApp ();

  Ego *
    findEgo (const QString pubKeyStr);

  void
    placeCreate (GNUNET_SOCIAL_Ego *ego);

  void
    placeEnter (GNUNET_SOCIAL_Ego *ego,
                GNUNET_CRYPTO_EddsaPublicKey *pubKey,
                GNUNET_PeerIdentity *peerId);

  Q_INVOKABLE void
    createPlace (QString egoPubKeyStr);

  Q_INVOKABLE void
    enterPlace (QString egoPubKeyStr, QString pubKeyStr, QString peerIdStr);

  const QList<Ego *> &
    egos ()
  {
    return m_egos;
  }

  const QList<Place *> &
    places ()
  {
    return m_places;
  }

 signals:

  void
    createPlaceSignal (QString egoPubKeyStr);

  void
    enterPlaceSignal (QString egoPubKeyStr, QString pubKey, QString peerId);

  void
    egoAddedSignal (Ego *ego);

  void
    placeAddedSignal (Place *place);

 public slots:

  void
    createPlaceSlot (QString egoPubKeyStr);

  void
    enterPlaceSlot (QString egoPubKeyStr, QString pubKey, QString peerId);

 private:

  GNUNET_SOCIAL_App *m_app;
  QList<Ego *> m_egos;
  QList<Place *> m_places;
  GNUNET_CONFIGURATION_Handle *m_config;

  static void
    egoCallback (void *cls,
                 struct GNUNET_SOCIAL_Ego *ego,
                 const struct GNUNET_CRYPTO_EcdsaPublicKey *ego_pub_key,
                 const char *name);

  void
    addEgo (Ego *ego);

  void
    addPlace (Place *place);

  static void
    hostPlaceCallback (void *cls,
                       struct GNUNET_SOCIAL_HostConnection *hconn,
                       struct GNUNET_SOCIAL_Ego *ego,
                       const struct GNUNET_CRYPTO_EddsaPublicKey *placePubKey,
                       enum GNUNET_SOCIAL_AppPlaceState placeState);

  static void
    guestPlaceCallback (void *cls,
                        struct GNUNET_SOCIAL_GuestConnection *gconn,
                        struct GNUNET_SOCIAL_Ego *ego,
                        const struct GNUNET_CRYPTO_EddsaPublicKey *placePubKey,
                        enum GNUNET_SOCIAL_AppPlaceState placeState);

};

#endif