From fdd50e49e8e7598984700872bd7720f9daec7f58 Mon Sep 17 00:00:00 2001 From: "tg(x)" <*@tg-x.net> Date: Fri, 18 Mar 2016 00:53:30 +0100 Subject: models --- secushare.pro | 2 + src/app.cpp | 30 +++++++-- src/app.h | 26 +++++-- src/model/EgoListModel.cpp | 8 +-- src/model/EgoListModel.h | 4 +- src/model/NymListModel.cpp | 8 +-- src/model/NymListModel.h | 6 +- src/model/PlaceListModel.cpp | 60 +++++++++-------- src/model/PlaceListModel.h | 15 +++-- src/model/ThreadListModel.cpp | 153 ++++++++++++++++++++++++++++++++++++++++++ src/model/ThreadListModel.h | 69 +++++++++++++++++++ src/model/ThreadModel.cpp | 31 +++++++++ src/model/ThreadModel.h | 8 +++ src/social/message.cpp | 2 +- src/social/message.h | 5 +- src/social/nym.h | 5 +- src/social/place.cpp | 17 ++++- src/social/place.h | 34 ++++++---- src/social/socialapp.cpp | 37 +++------- src/social/socialapp.h | 22 ++---- 20 files changed, 423 insertions(+), 119 deletions(-) create mode 100644 src/model/ThreadListModel.cpp create mode 100644 src/model/ThreadListModel.h diff --git a/secushare.pro b/secushare.pro index bea042b..05da98d 100644 --- a/secushare.pro +++ b/secushare.pro @@ -25,6 +25,7 @@ SOURCES += src/main.cpp \ src/model/EgoListModel.cpp \ src/model/NymListModel.cpp \ src/model/PlaceListModel.cpp \ + src/model/ThreadListModel.cpp \ src/model/ThreadModel.cpp \ src/gnunet/gnunet.cpp \ src/social/socialapp.cpp \ @@ -55,6 +56,7 @@ HEADERS += \ src/model/EgoListModel.h \ src/model/NymListModel.h \ src/model/PlaceListModel.h \ + src/model/ThreadListModel.h \ src/model/ThreadModel.h \ src/social/socialapp.h \ src/social/nym.h \ diff --git a/src/app.cpp b/src/app.cpp index 91d3af7..c59856b 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -82,12 +82,20 @@ App::setConnected (bool connected) if (connected) { m_models->setEgos (new EgoListModel (m_gnunet->social ()->egos (), this)); - connect (m_gnunet->social (), &SocialApp::egoAddedSignal, - m_models->egos (), &EgoListModel::rowAddedSlot); + connect (m_gnunet->social (), &SocialApp::egoAdded, + m_models->egos (), &EgoListModel::rowAdded); m_models->setPlaces (new PlaceListModel (m_gnunet->social ()->places (), this)); - connect (m_gnunet->social (), &SocialApp::placeAddedSignal, - m_models->places (), &PlaceListModel::rowAddedSlot); + connect (m_gnunet->social (), &SocialApp::placeAdded, + m_models->places (), &PlaceListModel::rowAdded); + + // FIXME: threads + + connect (this, &App::createPlaceSignal, + m_gnunet->social (), &SocialApp::createPlaceSlot, Qt::QueuedConnection); + + connect (this, &App::enterPlaceSignal, + m_gnunet->social (), &SocialApp::enterPlaceSlot, Qt::QueuedConnection); } m_connected = connected; @@ -95,6 +103,20 @@ App::setConnected (bool connected) } +void +App::createPlace (QString egoPubKeyStr) +{ + emit createPlaceSignal (egoPubKeyStr); +} + + +void +App::enterPlace (QString egoPubKeyStr, QString pubKeyStr, QString peerIdStr) +{ + emit enterPlaceSignal (egoPubKeyStr, pubKeyStr, peerIdStr); +} + + // theApp singleton type provider static QObject * theApp_provider (QQmlEngine * engine, QJSEngine * scriptEngine) diff --git a/src/app.h b/src/app.h index d187806..eca9460 100644 --- a/src/app.h +++ b/src/app.h @@ -67,9 +67,20 @@ public: return m_gnunet ? m_gnunet->social () : NULL; } - void setupTray (); - Q_INVOKABLE void hide (); - Q_INVOKABLE void close (); + void + setupTray (); + + Q_INVOKABLE void + hide (); + + Q_INVOKABLE void + close (); + + Q_INVOKABLE void + createPlace (QString egoPubKeyStr); + + Q_INVOKABLE void + enterPlace (QString egoPubKeyStr, QString pubKeyStr, QString peerIdStr); void setConnected (bool connected); @@ -99,7 +110,14 @@ private: signals: - void connectedChanged (bool connected); + void + connectedChanged (bool connected); + + void + createPlaceSignal (QString egoPubKeyStr); + + void + enterPlaceSignal (QString egoPubKeyStr, QString pubKey, QString peerId); public slots: diff --git a/src/model/EgoListModel.cpp b/src/model/EgoListModel.cpp index 0e279bb..0cef0d4 100644 --- a/src/model/EgoListModel.cpp +++ b/src/model/EgoListModel.cpp @@ -80,14 +80,14 @@ EgoListModel::roleNames () const * An ego was added to the source data. */ void -EgoListModel::rowAddedSlot (Ego *ego) +EgoListModel::rowAdded (Ego *ego) { int index = m_data.count (); beginInsertRows (QModelIndex (), index, index); ego->setIndex (index); - connect (ego, &Ego::modifiedSignal, - this, &EgoListModel::rowModifiedSlot); + connect (ego, &Ego::modified, + this, &EgoListModel::rowModified); //m_lookupIndex[pubKey] = index; endInsertRows (); @@ -95,7 +95,7 @@ EgoListModel::rowAddedSlot (Ego *ego) void -EgoListModel::rowModifiedSlot (int index) +EgoListModel::rowModified (int index) { QModelIndex modelIndex = this->index (index); emit dataChanged (modelIndex, modelIndex); diff --git a/src/model/EgoListModel.h b/src/model/EgoListModel.h index c75aa07..bb2d94b 100644 --- a/src/model/EgoListModel.h +++ b/src/model/EgoListModel.h @@ -64,10 +64,10 @@ public: public slots: void - rowAddedSlot (Ego *ego); + rowAdded (Ego *ego); void - rowModifiedSlot (int index); + rowModified (int index); private slots: diff --git a/src/model/NymListModel.cpp b/src/model/NymListModel.cpp index da5ab17..76fa9a4 100644 --- a/src/model/NymListModel.cpp +++ b/src/model/NymListModel.cpp @@ -80,14 +80,14 @@ NymListModel::roleNames () const * An nym was added to the source data. */ void -NymListModel::rowAddedSlot (Nym *nym) +NymListModel::rowAdded (Nym *nym) { int index = m_data.count (); beginInsertRows (QModelIndex (), index, index); nym->setIndex (index); - connect (nym, &Nym::modifiedSignal, - this, &NymListModel::rowModifiedSlot); + connect (nym, &Nym::modified, + this, &NymListModel::rowModified); //m_lookupIndex[pubKey] = index; endInsertRows (); @@ -95,7 +95,7 @@ NymListModel::rowAddedSlot (Nym *nym) void -NymListModel::rowModifiedSlot (int index) +NymListModel::rowModified (int index) { QModelIndex modelIndex = this->index (index); emit dataChanged (modelIndex, modelIndex); diff --git a/src/model/NymListModel.h b/src/model/NymListModel.h index 01f8095..c680d98 100644 --- a/src/model/NymListModel.h +++ b/src/model/NymListModel.h @@ -64,12 +64,10 @@ public: public slots: void - rowAddedSlot (Nym *ego); + rowAdded (Nym *ego); void - rowModifiedSlot (int index); - -private slots: + rowModified (int index); private: diff --git a/src/model/PlaceListModel.cpp b/src/model/PlaceListModel.cpp index 896fa22..d14ac60 100644 --- a/src/model/PlaceListModel.cpp +++ b/src/model/PlaceListModel.cpp @@ -1,5 +1,6 @@ /* This file is part of SecureShare + (C) 2013 Bruno Cabral (and other contributing authors) SecureShare is free software; you can redistribute it and/or modify @@ -26,15 +27,20 @@ #include "PlaceListModel.h" -PlaceListModel::PlaceListModel (const QList &data, QObject * parent) +PlaceListModel::PlaceListModel (const QList &data, QObject *parent) : QAbstractListModel (parent), m_data (data) { + QListIterator it (m_data); + while (it.hasNext ()) + { + rowAdded (it.next ()); + } } int -PlaceListModel::rowCount (const QModelIndex & parent) const +PlaceListModel::rowCount (const QModelIndex &parent) const { Q_UNUSED (parent); return m_data.size (); @@ -42,32 +48,29 @@ PlaceListModel::rowCount (const QModelIndex & parent) const QVariant -PlaceListModel::data (const QModelIndex & index, int role) const +PlaceListModel::data (const QModelIndex &index, int role) const { - if (index.row () < 0 || index.row () >= m_data.count ()) - return QVariant (); + int idx = index.row (); + if (idx < 0 || m_data.count () <= idx) + return QVariant::Invalid; - Place *place = m_data[index.row ()]; + Place *place = m_data[idx]; switch (role) { case NAME: return place->name (); - break; case PUBKEY: return place->pubKeyString (); - break; case TYPE: return place->type (); - break; case DESC: return place->desc (); - break; + case THREADS: + return &m_threads[idx]; default: return QVariant::Invalid; } - - return QVariant::Invalid; } @@ -76,6 +79,7 @@ PlaceListModel::roleNames () const { QHash roles; + // FIXME: roles[PLACE] = "place"; roles[NAME] = "name"; roles[PUBKEY] = "pubKey"; roles[TYPE] = "type"; @@ -89,32 +93,34 @@ PlaceListModel::roleNames () const * A place was added to the source data. */ void -PlaceListModel::rowAddedSlot (Place *place) +PlaceListModel::rowAdded (Place *place) { - int index = m_data.count () - 1; - qDebug () << "PlaceListModel::rowAddedSlot: " << index; - - beginInsertRows (QModelIndex (), index, index); - place->setIndex (index); + int idx = m_data.count () - 1; + qDebug () << "PlaceListModel::rowAdded: " << idx; - connect (place, &Place::modifiedSignal, - this, &PlaceListModel::rowModifiedSlot); + m_threads += new ThreadListModel (place->threads (), this); - //m_lookupIndex[pubKey] = index; + beginInsertRows (QModelIndex (), idx, idx); endInsertRows (); + + connect (place, &Place::modified, + this, &PlaceListModel::rowModified); + + connect (place, &Place::threadAdded, + m_threads[idx], &ThreadListModel::rowAdded); } void -PlaceListModel::rowModifiedSlot (int index) +PlaceListModel::rowModified (Place *place) { - QModelIndex modelIndex = this->index (index); - emit dataChanged (modelIndex, modelIndex); + QModelIndex index = this->index (place->index ()); + emit dataChanged (index, index); } int -PlaceListModel::getCount () +PlaceListModel::count () { return m_data.count (); } @@ -123,7 +129,7 @@ PlaceListModel::getCount () Place * PlaceListModel::get (int index) { - if (index < 0 || getCount () < index) + if (index < 0 || count () < index) return NULL; Place *place = m_data[index]; @@ -138,7 +144,7 @@ PlaceListModel::get (int index) Place * PlaceListModel::get (QModelIndex index) { - if (getCount () < index.row ()) + if (count () < index.row ()) return NULL; return m_data[index.row ()]; diff --git a/src/model/PlaceListModel.h b/src/model/PlaceListModel.h index d93a3f4..b3c9941 100644 --- a/src/model/PlaceListModel.h +++ b/src/model/PlaceListModel.h @@ -23,6 +23,7 @@ #include +#include "ThreadListModel.h" #include "social/place.h" @@ -38,6 +39,7 @@ class PlaceListModel : public QAbstractListModel PUBKEY, TYPE, DESC, + THREADS, PLACELIST_ROLE_COUNT }; @@ -45,7 +47,7 @@ class PlaceListModel : public QAbstractListModel PlaceListModel (const QList &data, QObject *parent = 0); Q_INVOKABLE int - getCount (); + count (); Q_INVOKABLE Place * get (int index); @@ -64,22 +66,25 @@ class PlaceListModel : public QAbstractListModel public slots: void - rowAddedSlot (Place *place); + rowAdded (Place *place); void - rowModifiedSlot (int index); + rowModified (Place *place); private: int - rowCount (const QModelIndex & parent) const; + rowCount (const QModelIndex &parent) const; + QVariant data (const QModelIndex &index, int role) const; + QHash roleNames () const; const QList &m_data; - //QHash m_lookupIndex; + + QList m_threads; }; #endif diff --git a/src/model/ThreadListModel.cpp b/src/model/ThreadListModel.cpp new file mode 100644 index 0000000..02f0092 --- /dev/null +++ b/src/model/ThreadListModel.cpp @@ -0,0 +1,153 @@ +#include +#include +#include + +#include "ThreadListModel.h" + + +ThreadListModel::ThreadListModel (const QList &data, QObject * parent) + : QAbstractListModel (parent), + m_data (data) +{ + QListIterator it (m_data); + while (it.hasNext ()) + { + rowAdded (it.next ()); + } +} + + +int +ThreadListModel::rowCount (const QModelIndex & parent) const +{ + Q_UNUSED (parent); + return m_data.size (); +} + + +QVariant +ThreadListModel::data (const QModelIndex & index, int role) const +{ + int idx = index.row (); + if (idx < 0 || m_data.count () <= idx) + return QVariant::Invalid; + + Message *msg = m_data[idx]; + + switch (role) + { +#if FIXME + case NAME: + return msg->name (); + case PUBKEY: + return msg->pubKeyString (); + case TYPE: + return msg->type (); + case DESC: + return msg->desc (); +#endif + default: + return QVariant::Invalid; + } +} + + +QHash +ThreadListModel::roleNames () const +{ + QHash roles; + + roles[TITLE] = "title"; + roles[TEXT] = "text"; + roles[TYPE] = "type"; + roles[PUBKEY] = "pubKey"; + + return roles; +} + + +/** + * A message was added to the source data. + */ +void +ThreadListModel::rowAdded (Message *msg) +{ + int idx = m_data.count () - 1; + qDebug () << "ThreadListModel::rowAdded: " << idx; + + m_thread += new ThreadModel (msg, this); + + beginInsertRows (QModelIndex (), idx, idx); + endInsertRows (); + + connect (msg, &Message::modified, + this, &ThreadListModel::rowModified); + + connect (msg, &Message::childAdded, + m_thread[idx], &ThreadModel::rowAdded); + +} + + +void +ThreadListModel::rowModified (Message *msg) +{ + QModelIndex index = this->index (msg->index ()); + emit dataChanged (index, index); +} + + +int +ThreadListModel::count () +{ + return m_data.count (); +} + + +Message * +ThreadListModel::get (int index) +{ + if (index < 0 || count () < index) + return NULL; + + Message *msg = m_data[index]; + + //Set the ownership so QML don't delete it. + QQmlEngine::setObjectOwnership (msg, QQmlEngine::CppOwnership); + + return msg; +} + + +Message * +ThreadListModel::get (QModelIndex index) +{ + if (count () < index.row ()) + return NULL; + + return m_data[index.row ()]; +} + + +#if FIXME +bool +ThreadListModel::contains (QString id) +{ + return m_lookupIndex.contains (id); +} + + +Message * +ThreadListModel::get (QString key) +{ + if (m_lookupIndex.contains (key)) + { + Message *msg = m_data[m_lookupIndex[key]]; + + return msg; + + } + else + return NULL; +} +#endif diff --git a/src/model/ThreadListModel.h b/src/model/ThreadListModel.h new file mode 100644 index 0000000..d5a664d --- /dev/null +++ b/src/model/ThreadListModel.h @@ -0,0 +1,69 @@ +#ifndef THREADLISTMODEL_H +#define THREADLISTMODEL_H + +#include + +#include "ThreadModel.h" +#include "social/place.h" + + +class ThreadListModel : public QAbstractListModel +{ + Q_OBJECT; + + public: + + enum ThreadListRoles + { + TITLE = Qt::UserRole + 1, + TYPE, + TEXT, + PUBKEY, + THREADLIST_ROLE_COUNT + }; + + explicit + ThreadListModel (const QList &data, QObject *parent = 0); + + Q_INVOKABLE int + count (); + + Q_INVOKABLE Message * + get (int index); + + Message * + get (QModelIndex index); + +#if FIXME + bool + contains (QString id); + + Message * + get (QString key); +#endif + + public slots: + + void + rowAdded (Message *msg); + + void + rowModified (Message *msg); + + private: + + int + rowCount (const QModelIndex &parent) const; + + QVariant + data (const QModelIndex &index, int role) const; + + QHash + roleNames () const; + + const QList &m_data; + + QList m_thread; +}; + +#endif diff --git a/src/model/ThreadModel.cpp b/src/model/ThreadModel.cpp index a41b6a2..e72d2e6 100644 --- a/src/model/ThreadModel.cpp +++ b/src/model/ThreadModel.cpp @@ -93,3 +93,34 @@ ThreadModel::rowCount (const QModelIndex &parent) const return msg->childrenCount (); } + + +/** + * A message was added to the source data. + */ +void +ThreadModel::rowAdded (Message *msg) +{ +#if FIXME + int idx = m_data.count () - 1; + + beginInsertRows (QModelIndex (), idx, idx); + endInsertRows (); + + connect (msg, &Message::modified, + this, &ThreadModel::rowModified); + + connect (msg, &Message::childAdded, + this, &ThreadModel::rowAdded); +#endif +} + + +void +ThreadModel::rowModified (Message *msg) +{ +#if FIXME + QModelIndex index = this->index (msg->index ()); + emit dataChanged (index, index); +#endif +} diff --git a/src/model/ThreadModel.h b/src/model/ThreadModel.h index 7d48afc..656373b 100644 --- a/src/model/ThreadModel.h +++ b/src/model/ThreadModel.h @@ -45,6 +45,14 @@ class ThreadModel : public QAbstractItemModel columnCount (const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; + public slots: + + void + rowAdded (Message *msg); + + void + rowModified (Message *msg); + private: Message *m_root; diff --git a/src/social/message.cpp b/src/social/message.cpp index db5bf7b..41b1d3a 100644 --- a/src/social/message.cpp +++ b/src/social/message.cpp @@ -155,7 +155,7 @@ Message::appendChild (Message *msg) { m_children.append (msg); msg->setParent (this); - emit messageAdded (msg); + emit childAdded (msg); } diff --git a/src/social/message.h b/src/social/message.h index f45395a..5e36477 100644 --- a/src/social/message.h +++ b/src/social/message.h @@ -181,7 +181,10 @@ class Message : public QObject signals: void - messageAdded (Message *msg); + modified (Message *msg); + + void + childAdded (Message *msg); private: diff --git a/src/social/nym.h b/src/social/nym.h index d961c69..9c7b88b 100644 --- a/src/social/nym.h +++ b/src/social/nym.h @@ -44,7 +44,7 @@ class Nym : public QObject { m_name = name; emit nameChanged (name); - emit modifiedSignal (m_index); + emit modified (m_index); } @@ -72,6 +72,7 @@ class Nym : public QObject { m_name = m_pubKeyStr.left (8); } + emit modified (m_index); } QString @@ -104,7 +105,7 @@ class Nym : public QObject signals: - void modifiedSignal (int index); + void modified (int index); void nameChanged (QString name); }; diff --git a/src/social/place.cpp b/src/social/place.cpp index b7e5179..8b1f4f3 100644 --- a/src/social/place.cpp +++ b/src/social/place.cpp @@ -20,8 +20,10 @@ Place::Place (QObject *parent) : QObject (parent) m_msg = 0; m_mod = 0; - connect (this, &Place::setTrayMessageSignal, + #if FIXME + connect (this, &Place::setTrayMessage, theApp, &App::setTrayMessage, Qt::QueuedConnection); + #endif } void @@ -229,6 +231,7 @@ Place::insertMessage (Message *msg) // Find thread + bool newThread = false; uint64_t threadId = 0; Modifier *mod = msg->findModifier ("_id_thread"); if (mod) @@ -256,8 +259,9 @@ Place::insertMessage (Message *msg) } } + m_threads += thread; m_threadHash.insert (threadId, thread); - m_threadList.append (thread); + newThread = true; } // Find parent message @@ -276,6 +280,13 @@ Place::insertMessage (Message *msg) if (parent) parent->appendChild (msg); + + emit messageReceived (msg, parent, thread); + + if (newThread) + { + emit threadAdded (msg); + } } @@ -303,6 +314,6 @@ Place::notifyData (uint16_t *data_size, void *data) return GNUNET_NO; m_inTransmit = false; - emit dataSentSignal (); + emit dataSent (); return GNUNET_YES; } diff --git a/src/social/place.h b/src/social/place.h index f59c444..c5445be 100644 --- a/src/social/place.h +++ b/src/social/place.h @@ -5,8 +5,6 @@ #include "message.h" #include "gnunet.h" -#define DATA2ARG(data) data, sizeof (data) - class Place : public QObject { @@ -39,7 +37,7 @@ class Place : public QObject { m_name = name; emit nameChanged (name); - emit modifiedSignal (m_index); + emit modified (this); } // Desc @@ -51,7 +49,7 @@ class Place : public QObject { m_desc = desc; emit descChanged (desc); - emit modifiedSignal (m_index); + emit modified (this); } //Type @@ -63,7 +61,7 @@ class Place : public QObject { m_type = type; emit typeChanged (type); - emit modifiedSignal (m_index); + emit modified (this); } //Is Host ? @@ -90,7 +88,13 @@ class Place : public QObject m_pubKeyStr = QString::fromLatin1 (pubKeyChr); GNUNET_free (pubKeyChr); emit pubKeyStringChanged (m_pubKeyStr); - emit modifiedSignal (m_index); + emit modified (this); + } + + const QList & + threads () + { + return m_threads; } Q_INVOKABLE void @@ -116,7 +120,7 @@ class Place : public QObject Modifier *m_mod; /// List of top-level, thread-starting messages. - QList m_threadList; + QList m_threads; /// _thread_id -> thread starter Message QHash m_threadHash; @@ -124,8 +128,6 @@ class Place : public QObject /// _message_id -> Message QHash m_msgHash; - // FIXME: ThreadListModel m_threads; - QString m_pubKeyStr; GNUNET_CRYPTO_EddsaPublicKey m_pubKey; @@ -220,7 +222,7 @@ class Place : public QObject signals: - void modifiedSignal (int index); + void modified (Place *place); void pubKeyStringChanged (QString pubKeyString); @@ -230,11 +232,17 @@ class Place : public QObject void typeChanged (QString type); - void talkSignal (QString text); + void dataSent (); + + void messageReceived (Message *msg, Message *parent, Message *thread); - void dataSentSignal (); + void threadAdded (Message *msg); - void setTrayMessageSignal (QString place, QString text); +#if FIXME + void talkSignal (QString text); + + void setTrayMessage (QString place, QString text); +#endif public slots: diff --git a/src/social/socialapp.cpp b/src/social/socialapp.cpp index 027f650..75279fd 100644 --- a/src/social/socialapp.cpp +++ b/src/social/socialapp.cpp @@ -16,12 +16,6 @@ SocialApp::SocialApp (struct GNUNET_CONFIGURATION_Handle *config, hostPlaceCallback, guestPlaceCallback, this); - - connect (this, &SocialApp::createPlaceSignal, - this, &SocialApp::createPlaceSlot, Qt::QueuedConnection); - - connect (this, &SocialApp::enterPlaceSignal, - this, &SocialApp::enterPlaceSlot, Qt::QueuedConnection); } @@ -46,14 +40,15 @@ void SocialApp::addEgo (Ego *ego) { m_egos += ego; - emit egoAddedSignal (ego); + emit egoAdded (ego); } void SocialApp::addPlace (Place *place) { m_places += place; - emit placeAddedSignal (place); + place->setIndex (m_places.count () - 1); + emit placeAdded (place); } void @@ -95,7 +90,7 @@ SocialApp::findEgo (const QString pubKeyStr) void -SocialApp::placeCreate (GNUNET_SOCIAL_Ego *ego) +SocialApp::createPlace (GNUNET_SOCIAL_Ego *ego) { addPlace (new Host (m_app, ego, GNUNET_PSYC_CHANNEL_PRIVATE, this)); } @@ -113,21 +108,14 @@ SocialApp::createPlaceSlot (QString egoPubKeyStr) ego = m_egos.last (); } - placeCreate (ego->ego ()); -} - - -void -SocialApp::createPlace (QString egoPubKeyStr) -{ - emit createPlaceSignal (egoPubKeyStr); + createPlace (ego->ego ()); } void -SocialApp::placeEnter (GNUNET_SOCIAL_Ego *ego, - GNUNET_CRYPTO_EddsaPublicKey *pubKey, - GNUNET_PeerIdentity *peerId) +SocialApp::enterPlace (GNUNET_SOCIAL_Ego *ego, + GNUNET_CRYPTO_EddsaPublicKey *pubKey, + GNUNET_PeerIdentity *peerId) { addPlace (new Guest (m_app, ego, pubKey, peerId, 0, NULL, NULL, this)); } @@ -159,12 +147,5 @@ SocialApp::enterPlaceSlot (QString egoPubKeyStr, QString pubKeyStr, QString peer ego = m_egos.last (); } - placeEnter (ego->ego (), &pubKey, &peerId); -} - - -void -SocialApp::enterPlace (QString egoPubKeyStr, QString pubKeyStr, QString peerIdStr) -{ - emit enterPlaceSignal (egoPubKeyStr, pubKeyStr, peerIdStr); + enterPlace (ego->ego (), &pubKey, &peerId); } diff --git a/src/social/socialapp.h b/src/social/socialapp.h index 0800b14..7bb7219 100644 --- a/src/social/socialapp.h +++ b/src/social/socialapp.h @@ -22,19 +22,13 @@ class SocialApp : public QObject findEgo (const QString pubKeyStr); void - placeCreate (GNUNET_SOCIAL_Ego *ego); + createPlace (GNUNET_SOCIAL_Ego *ego); void - placeEnter (GNUNET_SOCIAL_Ego *ego, + enterPlace (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 & egos () { @@ -50,16 +44,10 @@ class SocialApp : public QObject signals: void - createPlaceSignal (QString egoPubKeyStr); - - void - enterPlaceSignal (QString egoPubKeyStr, QString pubKey, QString peerId); - - void - egoAddedSignal (Ego *ego); + egoAdded (Ego *ego); void - placeAddedSignal (Place *place); + placeAdded (Place *place); public slots: @@ -67,7 +55,7 @@ class SocialApp : public QObject createPlaceSlot (QString egoPubKeyStr); void - enterPlaceSlot (QString egoPubKeyStr, QString pubKey, QString peerId); + enterPlaceSlot (QString egoPubKeyStr, QString pubKeyStr, QString peerIdStr); private: -- cgit v1.2.3