[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r36877 - in gnunet-qt/secushare: core core/gnunet core/iden
From: |
gnunet |
Subject: |
[GNUnet-SVN] r36877 - in gnunet-qt/secushare: core core/gnunet core/identity core/social models |
Date: |
Wed, 27 Jan 2016 21:45:47 +0100 |
Author: tg
Date: 2016-01-27 21:45:46 +0100 (Wed, 27 Jan 2016)
New Revision: 36877
Modified:
gnunet-qt/secushare/core/gnunet/gnunet_includes.h
gnunet-qt/secushare/core/identity/identityService.h
gnunet-qt/secushare/core/psyccore.cpp
gnunet-qt/secushare/core/psyccore.h
gnunet-qt/secushare/core/social/place.cpp
gnunet-qt/secushare/core/social/place.h
gnunet-qt/secushare/core/social/socialservice.cpp
gnunet-qt/secushare/core/social/socialservice.h
gnunet-qt/secushare/models/PlacesModel.cpp
gnunet-qt/secushare/models/PlacesModel.h
Log:
api changes
Modified: gnunet-qt/secushare/core/gnunet/gnunet_includes.h
===================================================================
--- gnunet-qt/secushare/core/gnunet/gnunet_includes.h 2016-01-27 20:45:38 UTC
(rev 36876)
+++ gnunet-qt/secushare/core/gnunet/gnunet_includes.h 2016-01-27 20:45:46 UTC
(rev 36877)
@@ -43,7 +43,6 @@
#include <gnunet/gnunet_friends_lib.h>
#include <gnunet/gnunet_social_service.h>
#include <gnunet/gnunet_psyc_util_lib.h>
-#include <gnunet/gnunet_env_lib.h>
#endif // GNUNET_INCLUDES_H
Modified: gnunet-qt/secushare/core/identity/identityService.h
===================================================================
--- gnunet-qt/secushare/core/identity/identityService.h 2016-01-27 20:45:38 UTC
(rev 36876)
+++ gnunet-qt/secushare/core/identity/identityService.h 2016-01-27 20:45:46 UTC
(rev 36877)
@@ -22,8 +22,8 @@
private:
struct GNUNET_CONFIGURATION_Handle *m_config;
/**
- * Handle to IDENTITY service.
- */
+ * Handle to IDENTITY service.
+ */
struct GNUNET_IDENTITY_Handle *m_identityHandle;
};
Modified: gnunet-qt/secushare/core/psyccore.cpp
===================================================================
--- gnunet-qt/secushare/core/psyccore.cpp 2016-01-27 20:45:38 UTC (rev
36876)
+++ gnunet-qt/secushare/core/psyccore.cpp 2016-01-27 20:45:46 UTC (rev
36877)
@@ -148,16 +148,10 @@
* @param message
*/
void
-PsycCore::setTrayMessage (QString room, QString message)
+PsycCore::setTrayMessage (QString place, QString message)
{
-
-
if (!theWindow->isVisible ())
{
-
- m_tray->showMessage (room, message);
-
+ m_tray->showMessage (place, message);
}
-
-
}
Modified: gnunet-qt/secushare/core/psyccore.h
===================================================================
--- gnunet-qt/secushare/core/psyccore.h 2016-01-27 20:45:38 UTC (rev 36876)
+++ gnunet-qt/secushare/core/psyccore.h 2016-01-27 20:45:46 UTC (rev 36877)
@@ -88,7 +88,7 @@
void setIdentitySignal ();
public slots:void trayActivated (QSystemTrayIcon::ActivationReason reason);
- void setTrayMessage (QString room, QString message);
+ void setTrayMessage (QString place, QString message);
};
//Those are the externals visible to the whole application ( globals)
Modified: gnunet-qt/secushare/core/social/place.cpp
===================================================================
--- gnunet-qt/secushare/core/social/place.cpp 2016-01-27 20:45:38 UTC (rev
36876)
+++ gnunet-qt/secushare/core/social/place.cpp 2016-01-27 20:45:46 UTC (rev
36877)
@@ -11,10 +11,9 @@
* @param key
* @param parent
*/
-Place::Place (QString key, QObject * parent):
+Place::Place (QObject *parent):
QObject (parent)
{
- m_key = key;
m_status = "No status";
m_name = "No name";
m_type = "group"; //thread;group;contact
@@ -39,7 +38,7 @@
}
/**
- * @brief Place::talk , talk in the room
+ * @brief Place::talk , talk in the place
* @param text
*/
void
Modified: gnunet-qt/secushare/core/social/place.h
===================================================================
--- gnunet-qt/secushare/core/social/place.h 2016-01-27 20:45:38 UTC (rev
36876)
+++ gnunet-qt/secushare/core/social/place.h 2016-01-27 20:45:46 UTC (rev
36877)
@@ -2,7 +2,9 @@
#define PLACE_H
#include <QObject>
+#include "core/gnunet/gnunet_includes.h"
+
class Place:public QObject
{
@@ -13,7 +15,7 @@
public:
- explicit Place (QString key, QObject * parent = 0);
+ explicit Place (QObject * parent = 0);
//Index
int getIndex () const
@@ -81,11 +83,11 @@
}
//Slicer
- struct GNUNET_SOCIAL_Slicer *slicer () const
+ struct GNUNET_PSYC_Slicer *slicer () const
{
return m_slicer;
}
- void setSlicer (struct GNUNET_SOCIAL_Slicer *slicer)
+ void setSlicer (struct GNUNET_PSYC_Slicer *slicer)
{
m_slicer = slicer;
}
@@ -107,25 +109,18 @@
return m_isHost;
}
- //Private Key
- const struct GNUNET_CRYPTO_EddsaPrivateKey *privateKey () const
- {
- return m_placeKey;
- }
-
- void setPrivateKey (const struct GNUNET_CRYPTO_EddsaPrivateKey *key)
- {
- m_placeKey = key;
- }
-
//Public Key
const struct GNUNET_CRYPTO_EddsaPublicKey *publicKey () const
{
return m_placePubKey;
}
+
void setPublicKey (const struct GNUNET_CRYPTO_EddsaPublicKey *key)
{
m_placePubKey = key;
+ char *pubKeyChr = GNUNET_CRYPTO_eddsa_public_key_to_string (key);
+ m_key = QString::fromLatin1 (pubKeyChr);
+ GNUNET_free (pubKeyChr);
}
Q_INVOKABLE void copyToClipboard ();
@@ -156,7 +151,7 @@
//For hosts
bool m_isHost;
- struct GNUNET_SOCIAL_Slicer *m_slicer;
+ struct GNUNET_PSYC_Slicer *m_slicer;
struct GNUNET_SOCIAL_Host *m_hst;
@@ -183,7 +178,7 @@
void addConversationSignal (QString text);
- void setTrayMessageSignal (QString room, QString text);
+ void setTrayMessageSignal (QString place, QString text);
public slots:void addConversationSlot (QString text);
Modified: gnunet-qt/secushare/core/social/socialservice.cpp
===================================================================
--- gnunet-qt/secushare/core/social/socialservice.cpp 2016-01-27 20:45:38 UTC
(rev 36876)
+++ gnunet-qt/secushare/core/social/socialservice.cpp 2016-01-27 20:45:46 UTC
(rev 36877)
@@ -22,8 +22,8 @@
connect (this, &SocialService::createPlaceSignal, this,
&SocialService::createPlaceSlot, Qt::QueuedConnection);
- connect (this, &SocialService::enterRoomSignal, this,
- &SocialService::enterRoomSlot, Qt::QueuedConnection);
+ connect (this, &SocialService::enterPlaceSignal, this,
+ &SocialService::enterPlaceSlot, Qt::QueuedConnection);
}
@@ -35,116 +35,150 @@
SocialService::start (struct GNUNET_CONFIGURATION_Handle *config)
{
this->m_config = config;
+ this->m_app =
+ GNUNET_SOCIAL_app_connect (config, "secushare",
+ appEgoCallback,
+ appHostPlaceCallback,
+ appGuestPlaceCallback,
+ this);
+}
- //Grab selected identity at home screen
- Identity *id = theApp->identity ();
- m_hostEgo = id->ego ();
-
- GNUNET_SOCIAL_place_listen_start (config, m_hostEgo,
- placeNotifyHostCallback,
- placeNotifyGuestCallback,
- this);
+void
+SocialService::appEgoCallback (void *cls,
+ struct GNUNET_SOCIAL_Ego *ego,
+ const struct GNUNET_CRYPTO_EcdsaPublicKey
*ego_pub_key,
+ const char *name)
+{
+ SocialService *s = (SocialService *) cls;
+ s->m_hostEgo = ego; // FIXME
}
-
void
-SocialService::placeNotifyHostCallback (void *cls,
- const struct
GNUNET_CRYPTO_EddsaPrivateKey *placeKey,
- enum GNUNET_PSYC_Policy policy)
+SocialService::appHostPlaceCallback (void *cls,
+ struct GNUNET_SOCIAL_HostConnection
*hconn,
+ struct GNUNET_SOCIAL_Ego *ego,
+ const struct GNUNET_CRYPTO_EddsaPublicKey
*placePubKey,
+ enum GNUNET_SOCIAL_PlaceState placeState)
{
SocialService *s = (SocialService *) cls;
- s->hostEnterPlace (placeKey, policy);
+ s->hostEnterPlaceReconnect (hconn, ego, placePubKey, placeState);
}
void
-SocialService::placeNotifyGuestCallback (void *cls,
- const struct
GNUNET_CRYPTO_EddsaPublicKey *placePubKey,
- const struct GNUNET_PeerIdentity
*origin,
- uint32_t relayCount,
- const struct GNUNET_PeerIdentity
*relays,
- const struct GNUNET_PSYC_Message
*entryMsg)
+SocialService::appGuestPlaceCallback (void *cls,
+ struct GNUNET_SOCIAL_GuestConnection
*gconn,
+ struct GNUNET_SOCIAL_Ego *ego,
+ const struct
GNUNET_CRYPTO_EddsaPublicKey *placePubKey,
+ enum GNUNET_SOCIAL_PlaceState placeState)
{
SocialService *s = (SocialService *) cls;
- s->guestEnterPlace (placePubKey, origin, relayCount, relays, entryMsg);
+ s->guestEnterPlaceReconnect (gconn, ego, placePubKey, placeState);
}
-GNUNET_SOCIAL_Host *
-SocialService::hostEnterPlace (const GNUNET_CRYPTO_EddsaPrivateKey *placeKey,
- enum GNUNET_PSYC_Policy policy)
+void
+SocialService::createPlaceSlot (QString name)
{
- GNUNET_CRYPTO_EddsaPublicKey *placePubKey = new GNUNET_CRYPTO_EddsaPublicKey;
- GNUNET_CRYPTO_eddsa_key_get_public (placeKey, placePubKey);
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Creating a New Place.\n");
- char *placePubKeyChars = GNUNET_CRYPTO_eddsa_public_key_to_string
(placePubKey);
- QString placePubKeyStr = QString::fromLatin1 (placePubKeyChars);
+ hostEnterPlace (GNUNET_PSYC_CHANNEL_PRIVATE);
+}
- Place *newPlace = theApp->models ()->placesModel ()->add (placePubKeyStr);
- newPlace->setName (placePubKeyStr);
- newPlace->setPrivateKey (placeKey);
- newPlace->setPublicKey (placePubKey);
-
- GNUNET_SOCIAL_Slicer *slicer = GNUNET_SOCIAL_slicer_create ();
- GNUNET_SOCIAL_slicer_method_add (slicer, "",
- hostRecvMethodCallback,
- hostRecvModifierCallback,
- hostRecvDataCallback,
- hostRecvEomCallback,
- newPlace);
- newPlace->setSlicer (slicer);
-
- GNUNET_SOCIAL_Host *host =
- GNUNET_SOCIAL_host_enter (m_config, m_hostEgo, placeKey,
- policy, slicer,
- hostEnteredCallback,
- hostAnswerDoorCallback,
- hostFarewellCallback,
- newPlace);
-
- newPlace->setHost (host);
- connect (newPlace, &Place::hostTalkSignal, this, &SocialService::hostTalk,
- Qt::QueuedConnection);
+void
+SocialService::createPlace (QString name)
+{
+ emit createPlaceSignal (name);
}
void
-SocialService::createPlaceSlot (QString name)
+SocialService::initPlace (Place *place, const GNUNET_CRYPTO_EddsaPublicKey
*placePubKey)
{
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Creating a New Place.\n");
+ char *placePubKeyChars = GNUNET_CRYPTO_eddsa_public_key_to_string
(placePubKey);
+ QString placePubKeyStr = QString::fromLatin1 (placePubKeyChars);
- GNUNET_CRYPTO_EddsaPrivateKey *placeKey = GNUNET_CRYPTO_eddsa_key_create ();
- GNUNET_SOCIAL_Host *
- host = hostEnterPlace (placeKey, GNUNET_PSYC_CHANNEL_PRIVATE);
+ place->setPublicKey (placePubKey);
+ place->setName (placePubKeyStr);
+ theApp->models()->placesModel()->add(place);
+
+#if FIXME
if (0 < name.length ())
{
- GNUNET_CRYPTO_EddsaPublicKey *placePubKey = new
GNUNET_CRYPTO_EddsaPublicKey;
- GNUNET_CRYPTO_eddsa_key_get_public (placeKey, placePubKey);
-
- GNUNET_SOCIAL_host_advertise (host, name.toStdString ().c_str (),
- 0, NULL,
+ GNUNET_SOCIAL_zone_add_place (app, ego, name.toStdString().c_str(), NULL,
+ placePubKey, NULL, 0, NULL,
GNUNET_TIME_relative_to_absolute
(GNUNET_TIME_UNIT_MONTHS),
- NULL, NULL, NULL);
+ NULL, NULL);
}
+#endif
}
void
-SocialService::createPlace (QString name)
+SocialService::hostEnterPlace (enum GNUNET_PSYC_Policy policy)
{
- emit createPlaceSignal (name);
+ Place *place = new Place ();
+
+ GNUNET_PSYC_Slicer *slicer = GNUNET_PSYC_slicer_create ();
+ GNUNET_PSYC_slicer_method_add (slicer, "", NULL,
+ hostRecvMethodCallback,
+ hostRecvModifierCallback,
+ hostRecvDataCallback,
+ hostRecvEomCallback,
+ place);
+ place->setSlicer (slicer);
+
+ GNUNET_SOCIAL_Host *host =
+ GNUNET_SOCIAL_host_enter (m_app, m_hostEgo,
+ policy, slicer,
+ hostEnterCallback,
+ hostAnswerDoorCallback,
+ hostFarewellCallback,
+ place);
+ place->setHost (host);
+
+ connect (place, &Place::hostTalkSignal, this, &SocialService::hostTalk,
+ Qt::QueuedConnection);
}
+void
+SocialService::hostEnterPlaceReconnect (struct GNUNET_SOCIAL_HostConnection
*hconn,
+ struct GNUNET_SOCIAL_Ego *ego,
+ const struct
GNUNET_CRYPTO_EddsaPublicKey *placePubKey,
+ enum GNUNET_SOCIAL_PlaceState
placeState)
+{
+ Place *place = new Place ();
+ GNUNET_PSYC_Slicer *slicer = GNUNET_PSYC_slicer_create ();
+ GNUNET_PSYC_slicer_method_add (slicer, "", NULL,
+ hostRecvMethodCallback,
+ hostRecvModifierCallback,
+ hostRecvDataCallback,
+ hostRecvEomCallback,
+ place);
+ place->setSlicer (slicer);
+
+ GNUNET_SOCIAL_Host *host =
+ GNUNET_SOCIAL_host_enter_reconnect (hconn, slicer,
+ hostEnterCallback,
+ hostAnswerDoorCallback,
+ hostFarewellCallback,
+ place);
+ place->setHost (host);
+
+ connect (place, &Place::hostTalkSignal, this, &SocialService::hostTalk,
+ Qt::QueuedConnection);
+}
+
+
void
SocialService::hostRecvMethodCallback (void *cls,
+ const struct GNUNET_PSYC_MessageHeader
*msg,
const struct GNUNET_PSYC_MessageMethod
*meth,
uint64_t message_id,
- uint32_t flags,
- const struct GNUNET_SOCIAL_Nym *nym,
const char *method_name)
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -155,10 +189,12 @@
void
SocialService::hostRecvModifierCallback (void *cls,
- const struct GNUNET_MessageHeader
*msg,
+ const struct
GNUNET_PSYC_MessageHeader *msg,
+ const struct GNUNET_MessageHeader
*pmsg,
uint64_t message_id,
- enum GNUNET_ENV_Operator oper,
- const char *name, const void *value,
+ enum GNUNET_PSYC_Operator oper,
+ const char *name,
+ const void *value,
uint16_t value_size,
uint16_t full_value_size)
{
@@ -171,16 +207,18 @@
void
SocialService::hostRecvDataCallback (void *cls,
- const struct GNUNET_MessageHeader *msg,
- uint64_t message_id, uint64_t data_offset,
- const void *data, uint16_t data_size)
+ const struct GNUNET_PSYC_MessageHeader
*msg,
+ const struct GNUNET_MessageHeader *pmsg,
+ uint64_t message_id,
+ const void *data,
+ uint16_t data_size)
{
QString str = QString::fromLatin1 ((char *) data);
Place *place = (Place *) cls;
- qWarning () << "Host received data for message ID" << message_id << data_size
- << str;
+ qWarning () << "Host received data for message ID "
+ << message_id << data_size << str;
place->addConversation (str);
}
@@ -188,12 +226,14 @@
void
SocialService::hostRecvEomCallback (void *cls,
- const struct GNUNET_MessageHeader *msg,
- uint64_t message_id, uint8_t cancelled)
+ const struct GNUNET_PSYC_MessageHeader
*msg,
+ const struct GNUNET_MessageHeader *pmsg,
+ uint64_t message_id,
+ uint8_t is_cancelled)
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Test #: Host received end of message ID %i, cancelled: %u\n",
- message_id, cancelled);
+ message_id, is_cancelled);
}
@@ -200,7 +240,7 @@
void
SocialService::hostAnswerDoorCallback (void *cls, struct GNUNET_SOCIAL_Nym
*nym,
const char *method_name,
- struct GNUNET_ENV_Environment *env,
+ struct GNUNET_PSYC_Environment *env,
size_t data_size, const void *data)
{
@@ -214,7 +254,7 @@
void
SocialService::hostAnswerDoor (void *cls, struct GNUNET_SOCIAL_Nym *nym,
const char *method_name,
- struct GNUNET_ENV_Environment *env,
+ struct GNUNET_PSYC_Environment *env,
size_t data_size, const void *data)
{
@@ -239,23 +279,21 @@
void
-SocialService::hostEnteredCallback (void *cls, int result,
- uint64_t max_message_id)
+SocialService::hostEnterCallback (void *cls, int result,
+ const struct GNUNET_CRYPTO_EddsaPublicKey
*placePubKey,
+ uint64_t max_message_id)
{
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Host entered to place.\n");
-
- //GNUNET_IDENTITY_create (id, guest_name, &id_guest_created, NULL);
+ Place *place = (Place *) cls;
+ initPlace (place, placePubKey);
}
void
SocialService::hostFarewellCallback (void *cls,
const struct GNUNET_SOCIAL_Nym *nym,
- struct GNUNET_ENV_Environment *env)
+ struct GNUNET_PSYC_Environment *env)
{
- // FIXME: this function is not called yet
-
const struct GNUNET_CRYPTO_EcdsaPublicKey *nym_key =
- GNUNET_SOCIAL_nym_get_key (nym);
+ GNUNET_SOCIAL_nym_get_pub_key (nym);
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Nym %s has left the place.\n",
GNUNET_CRYPTO_ecdsa_public_key_to_string (nym_key));
}
@@ -263,16 +301,21 @@
void
SocialService::guestRecvLocalEnterCallback (void *cls, int result,
+ const struct
GNUNET_CRYPTO_EddsaPublicKey *placePubKey,
uint64_t max_message_id)
{
+ Place *place = (Place *) cls;
+ initPlace (place, placePubKey);
- theApp->gnunet ()->social ()->guestRecvLocalEnter (cls, result,
+ // FIXME
+ theApp->gnunet ()->social ()->guestRecvLocalEnter (place, result,
placePubKey,
max_message_id);
-
}
+
void
-SocialService::guestRecvLocalEnter (void *cls, int result,
+SocialService::guestRecvLocalEnter (Place *place, int result,
+ const struct GNUNET_CRYPTO_EddsaPublicKey
*placePubKey,
uint64_t max_message_id)
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -290,16 +333,13 @@
if (NULL != entry_msg)
{
- struct GNUNET_ENV_Environment *env = GNUNET_ENV_environment_create ();
-
+ struct GNUNET_PSYC_Environment *env = GNUNET_PSYC_env_create ();
const char *method_name = NULL;
-
const void *data = NULL;
-
uint16_t data_size = 0;
struct GNUNET_PSYC_MessageHeader *pmsg =
- GNUNET_PSYC_message_header_create_from_psyc (entry_msg);
+ GNUNET_PSYC_message_header_create_from_psyc (entry_msg);
GNUNET_PSYC_message_parse (pmsg, &method_name, env, &data, &data_size);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%s\n%.*s\n", method_name, data_size,
@@ -309,7 +349,7 @@
}
-GNUNET_SOCIAL_Guest *
+void
SocialService::guestEnterPlace (const GNUNET_CRYPTO_EddsaPublicKey
*placePubKey,
const GNUNET_PeerIdentity *origin,
uint32_t relayCount,
@@ -316,51 +356,69 @@
const GNUNET_PeerIdentity *relays,
const GNUNET_PSYC_Message *entryMsg)
{
- char *placePubKeyChars = GNUNET_CRYPTO_eddsa_public_key_to_string
(placePubKey);
- QString placePubKeyStr = QString::fromLatin1 (placePubKeyChars);
+ Place *place = new Place ();
- Place *newPlace = theApp->models ()->placesModel ()->add (placePubKeyStr);
- newPlace->setName (placePubKeyStr);
- newPlace->setPublicKey (placePubKey);
+ GNUNET_PSYC_Slicer *slicer = GNUNET_PSYC_slicer_create ();
- GNUNET_SOCIAL_Slicer *slicer = GNUNET_SOCIAL_slicer_create ();
+ GNUNET_PSYC_slicer_method_add (slicer, "", NULL,
+ &hostRecvMethodCallback,
+ &hostRecvModifierCallback,
+ &hostRecvDataCallback, &hostRecvEomCallback,
+ place);
+ place->setSlicer (slicer);
- GNUNET_SOCIAL_slicer_method_add (slicer, "", &hostRecvMethodCallback,
- &hostRecvModifierCallback,
- &hostRecvDataCallback, &hostRecvEomCallback,
- newPlace);
- newPlace->setSlicer (slicer);
-
- //TODO change place pub key to arbitrary value
GNUNET_SOCIAL_Guest *gst =
- GNUNET_SOCIAL_guest_enter (m_config, m_hostEgo, placePubKey,
+ GNUNET_SOCIAL_guest_enter (m_app, m_hostEgo, placePubKey,
+ GNUNET_PSYC_SLAVE_JOIN_NONE,
origin, 0, NULL, entryMsg,
slicer, &guestRecvLocalEnterCallback,
- &guestRecvEntryDecisionCallback, newPlace);
- newPlace->setSocialGuest (gst);
+ &guestRecvEntryDecisionCallback, place);
+ place->setSocialGuest (gst);
- connect (newPlace, &Place::guestTalkSignal, this, &SocialService::guestTalk,
+ connect (place, &Place::guestTalkSignal, this, &SocialService::guestTalk,
Qt::QueuedConnection);
}
void
-SocialService::enterRoomSlot (QString pubKeyStr, QString peerIdentity)
+SocialService::guestEnterPlaceReconnect (struct GNUNET_SOCIAL_GuestConnection
*gconn,
+ struct GNUNET_SOCIAL_Ego *ego,
+ const struct
GNUNET_CRYPTO_EddsaPublicKey *placePubKey,
+ enum GNUNET_SOCIAL_PlaceState
placeState)
{
+ Place *place = new Place ();
+
+ GNUNET_PSYC_Slicer *slicer = GNUNET_PSYC_slicer_create ();
+
+ GNUNET_PSYC_slicer_method_add (slicer, "", NULL,
+ &hostRecvMethodCallback,
+ &hostRecvModifierCallback,
+ &hostRecvDataCallback, &hostRecvEomCallback,
+ place);
+ place->setSlicer (slicer);
+
+ GNUNET_SOCIAL_Guest *gst =
+ GNUNET_SOCIAL_guest_enter_reconnect (gconn, GNUNET_PSYC_SLAVE_JOIN_NONE,
+ slicer, &guestRecvLocalEnterCallback,
+ place);
+ place->setSocialGuest (gst);
+
+ connect (place, &Place::guestTalkSignal, this, &SocialService::guestTalk,
+ Qt::QueuedConnection);
+}
+
+
+void
+SocialService::enterPlaceSlot (QString pubKeyStr, QString peerIdentity)
+{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Entering to place %s as guest.\n",
pubKeyStr.toStdString ().c_str ());
- GuestEnterMessage emsg;
- emsg.method_name = "_request_enter";
- emsg.env = GNUNET_ENV_environment_create ();
- GNUNET_ENV_environment_add (emsg.env, GNUNET_ENV_OP_ASSIGN, "_abc", "abc
def",
- 7);
- GNUNET_ENV_environment_add (emsg.env, GNUNET_ENV_OP_ASSIGN, "_abc_def",
- "abc def ghi", 11);
- emsg.data = "let me in";
- emsg.data_size = strlen (emsg.data) + 1;
- emsg.msg = GNUNET_PSYC_message_create (emsg.method_name, emsg.env,
- emsg.data, emsg.data_size);
+ GNUNET_PSYC_Environment *env = GNUNET_PSYC_env_create ();
+ GNUNET_PSYC_env_add (env, GNUNET_PSYC_OP_ASSIGN, "_abc", "abc def", 7);
+ GNUNET_PSYC_env_add (env, GNUNET_PSYC_OP_ASSIGN, "_abc_def", "abc def ghi",
11);
+ GNUNET_PSYC_Message *
+ msg = GNUNET_PSYC_message_create ("_request_enter", env, NULL, 0);
GNUNET_CRYPTO_EddsaPublicKey *pubKey = new GNUNET_CRYPTO_EddsaPublicKey;
@@ -370,14 +428,14 @@
pubKey))
return; // Failed conversion
- guestEnterPlace (pubKey, theApp->gnunet ()->myPeer (), 0, NULL, emsg.msg);
+ guestEnterPlace (pubKey, theApp->gnunet ()->myPeer (), 0, NULL, msg);
}
void
-SocialService::enterRoom (QString pubKey, QString peerIdentity)
+SocialService::enterPlace (QString pubKey, QString peerIdentity)
{
- emit enterRoomSignal (pubKey, peerIdentity);
+ emit enterPlaceSignal (pubKey, peerIdentity);
}
@@ -401,7 +459,7 @@
if (NULL != tmit->env)
{
- GNUNET_ENV_environment_destroy (tmit->env);
+ GNUNET_PSYC_env_destroy (tmit->env);
tmit->env = NULL;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "data_sent: %z, data_size: %u\n",
@@ -441,7 +499,7 @@
tmit->data_sent = 0;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "data: %s\n", tmit->data.c_str ());
tmit->host_ann =
- GNUNET_SOCIAL_host_announce (place->host (), "_message_host", tmit->env,
- ¬ify_data, tmit,
- GNUNET_SOCIAL_ANNOUNCE_NONE);
+ GNUNET_SOCIAL_host_announce (place->host (), "_message_host", tmit->env,
+ ¬ify_data, tmit,
+ GNUNET_SOCIAL_ANNOUNCE_NONE);
}
Modified: gnunet-qt/secushare/core/social/socialservice.h
===================================================================
--- gnunet-qt/secushare/core/social/socialservice.h 2016-01-27 20:45:38 UTC
(rev 36876)
+++ gnunet-qt/secushare/core/social/socialservice.h 2016-01-27 20:45:46 UTC
(rev 36877)
@@ -5,22 +5,12 @@
#include "core/gnunet/gnunet_includes.h"
-typedef struct GuestEnterMessage
-{
- struct GNUNET_PSYC_Message *msg;
- const char *method_name;
- struct GNUNET_ENV_Environment *env;
- char *data;
- uint16_t data_size;
-} GuestEnterMessage;
-
-
typedef struct TransmitClosure
{
struct GNUNET_SOCIAL_Announcement *host_ann;
struct GNUNET_SOCIAL_TalkRequest *guest_talk;
- struct GNUNET_ENV_Environment *env;
- std::string data;
+ struct GNUNET_PSYC_Environment *env;
+ std::string data;
size_t data_sent;
} TransmitClosure;
@@ -33,61 +23,76 @@
explicit SocialService (QObject * parent = 0);
static void
- placeNotifyHostCallback (void *cls,
- const struct GNUNET_CRYPTO_EddsaPrivateKey
*place_key,
- enum GNUNET_PSYC_Policy policy);
+ appEgoCallback (void *cls,
+ struct GNUNET_SOCIAL_Ego *ego,
+ const struct GNUNET_CRYPTO_EcdsaPublicKey *ego_pub_key,
+ const char *name);
static void
- placeNotifyGuestCallback (void *cls,
- const struct GNUNET_CRYPTO_EddsaPublicKey
*place_key,
- const struct GNUNET_PeerIdentity *origin,
- uint32_t relay_count,
- const struct GNUNET_PeerIdentity *relays,
- const struct GNUNET_PSYC_Message *entry_msg);
+ appHostPlaceCallback (void *cls,
+ struct GNUNET_SOCIAL_HostConnection *hconn,
+ struct GNUNET_SOCIAL_Ego *ego,
+ const struct GNUNET_CRYPTO_EddsaPublicKey *placePubKey,
+ enum GNUNET_SOCIAL_PlaceState placeState);
+ static void
+ appGuestPlaceCallback (void *cls,
+ struct GNUNET_SOCIAL_GuestConnection *gconn,
+ struct GNUNET_SOCIAL_Ego *ego,
+ const struct GNUNET_CRYPTO_EddsaPublicKey
*placePubKey,
+ enum GNUNET_SOCIAL_PlaceState placeState);
- GNUNET_SOCIAL_Host *
- hostEnterPlace (const GNUNET_CRYPTO_EddsaPrivateKey *placeKey,
- enum GNUNET_PSYC_Policy policy);
+ void
+ hostEnterPlace (enum GNUNET_PSYC_Policy policy);
+ void
+ hostEnterPlaceReconnect (struct GNUNET_SOCIAL_HostConnection *hconn,
+ struct GNUNET_SOCIAL_Ego *ego,
+ const struct GNUNET_CRYPTO_EddsaPublicKey
*placePubKey,
+ enum GNUNET_SOCIAL_PlaceState placeState);
+
static void hostRecvMethodCallback (void *cls,
- const struct GNUNET_PSYC_MessageMethod
- *meth, uint64_t message_id,
- uint32_t flags,
- const struct GNUNET_SOCIAL_Nym *nym,
+ const struct GNUNET_PSYC_MessageHeader
*msg,
+ const struct GNUNET_PSYC_MessageMethod
*meth,
+ uint64_t message_id,
const char *method_name);
static void hostRecvModifierCallback (void *cls,
- const struct GNUNET_MessageHeader *msg,
+ const struct GNUNET_PSYC_MessageHeader
*msg,
+ const struct GNUNET_MessageHeader
*pmsg,
uint64_t message_id,
- enum GNUNET_ENV_Operator oper,
+ enum GNUNET_PSYC_Operator oper,
const char *name, const void *value,
uint16_t value_size,
uint16_t full_value_size);
static void hostRecvDataCallback (void *cls,
- const struct GNUNET_MessageHeader *msg,
- uint64_t message_id, uint64_t data_offset,
- const void *data, uint16_t data_size);
+ const struct GNUNET_PSYC_MessageHeader
*msg,
+ const struct GNUNET_MessageHeader *pmsg,
+ uint64_t message_id,
+ const void *data,
+ uint16_t data_size);
static void hostRecvEomCallback (void *cls,
- const struct GNUNET_MessageHeader *msg,
- uint64_t message_id, uint8_t cancelled);
+ const struct GNUNET_PSYC_MessageHeader *msg,
+ const struct GNUNET_MessageHeader *pmsg,
+ uint64_t message_id,
+ uint8_t is_cancelled);
static void hostAnswerDoorCallback (void *cls, struct GNUNET_SOCIAL_Nym *nym,
const char *method_name,
- struct GNUNET_ENV_Environment *env,
+ struct GNUNET_PSYC_Environment *env,
size_t data_size, const void *data);
void hostAnswerDoor (void *cls, struct GNUNET_SOCIAL_Nym *nym,
const char *method_name,
- struct GNUNET_ENV_Environment *env, size_t data_size,
+ struct GNUNET_PSYC_Environment *env, size_t data_size,
const void *data);
- static void hostEnteredCallback (void *cls, int result,
- uint64_t max_message_id);
+ static void hostEnterCallback (void *cls, int result,
+ const struct GNUNET_CRYPTO_EddsaPublicKey
*placePubKey,
+ uint64_t max_message_id);
static void hostFarewellCallback (void *cls,
const struct GNUNET_SOCIAL_Nym *nym,
- struct GNUNET_ENV_Environment *env);
+ struct GNUNET_PSYC_Environment *env);
-
- GNUNET_SOCIAL_Guest *
+ void
guestEnterPlace (const GNUNET_CRYPTO_EddsaPublicKey *placePubKey,
const GNUNET_PeerIdentity *origin,
uint32_t relay_count,
@@ -94,6 +99,11 @@
const GNUNET_PeerIdentity *relays,
const GNUNET_PSYC_Message *entry_msg);
+ void
+ guestEnterPlaceReconnect (struct GNUNET_SOCIAL_GuestConnection *gconn,
+ struct GNUNET_SOCIAL_Ego *ego,
+ const struct GNUNET_CRYPTO_EddsaPublicKey
*placePubKey,
+ enum GNUNET_SOCIAL_PlaceState placeState);
static void guestRecvEntryDecisionCallback (void *cls, int is_admitted,
const struct GNUNET_PSYC_Message
@@ -100,26 +110,33 @@
*entry_resp);
static void guestRecvLocalEnterCallback (void *cls, int result,
+ const struct
GNUNET_CRYPTO_EddsaPublicKey *placePubKey,
uint64_t max_message_id);
- void guestRecvLocalEnter (void *cls, int result, uint64_t max_message_id);
+ void guestRecvLocalEnter (Place *place, int result,
+ const struct GNUNET_CRYPTO_EddsaPublicKey
*placePubKey,
+ uint64_t max_message_id);
+ static void
+ initPlace (Place *place, const GNUNET_CRYPTO_EddsaPublicKey *placePubKey);
void start (GNUNET_CONFIGURATION_Handle * config);
Q_INVOKABLE void createPlace (QString name);
void createPlaceSlot (QString name);
- Q_INVOKABLE void enterRoom (QString pubKey, QString peerIdentity);
+ Q_INVOKABLE void enterPlace (QString pubKey, QString peerIdentity);
+signals:
- signals:void createPlaceSignal (QString name);
- void enterRoomSignal (QString pubKey, QString peerIdentity);
- public slots:void enterRoomSlot (QString pubKey, QString peerIdentity);
+ void createPlaceSignal (QString name);
+ void enterPlaceSignal (QString pubKey, QString peerIdentity);
+ public slots:void enterPlaceSlot (QString pubKey, QString peerIdentity);
void guestTalk (Place * place, QString text);
void hostTalk (Place * place, QString text);
+
private:
- GNUNET_IDENTITY_Ego * m_hostEgo;
+ GNUNET_SOCIAL_Ego *m_hostEgo; // FIXME
+ GNUNET_SOCIAL_App *m_app;
GNUNET_CONFIGURATION_Handle *m_config;
-
};
#endif // SOCIALSERVICE_H
Modified: gnunet-qt/secushare/models/PlacesModel.cpp
===================================================================
--- gnunet-qt/secushare/models/PlacesModel.cpp 2016-01-27 20:45:38 UTC (rev
36876)
+++ gnunet-qt/secushare/models/PlacesModel.cpp 2016-01-27 20:45:46 UTC (rev
36877)
@@ -122,15 +122,11 @@
* @param key
* @return Return the new created place
*/
-Place *
-PlacesModel::add (QString key)
+void
+PlacesModel::add (Place *place)
{
- Place *place = new Place (key);
-
place->moveToThread (this->thread ());
- emit addNewPlaceSignal (place, key);
-
- return place;
+ emit addNewPlaceSignal (place, place->key ());
}
@@ -140,7 +136,7 @@
* @return return the same place as item
*/
Place *
-PlacesModel::addNewPlaceSlot (Place * item, QString key)
+PlacesModel::addNewPlaceSlot (Place *item, QString key)
{
//Search if already exists
Modified: gnunet-qt/secushare/models/PlacesModel.h
===================================================================
--- gnunet-qt/secushare/models/PlacesModel.h 2016-01-27 20:45:38 UTC (rev
36876)
+++ gnunet-qt/secushare/models/PlacesModel.h 2016-01-27 20:45:46 UTC (rev
36877)
@@ -45,7 +45,7 @@
explicit PlacesModel (QObject * parent = 0);
struct Bandwidth_Info_Struct *getTotalBandwidth ();
- Place *add (QString key);
+ void add (Place *place);
int getCount ();
bool contains (QString id);
@@ -58,7 +58,7 @@
~PlacesModel ();
signals:
- void addNewPlaceSignal (Place * item, QString key);
+ void addNewPlaceSignal (Place *item, QString key);
public slots:void modifiedSlot (int indexRow);
private slots:Place * addNewPlaceSlot (Place * item, QString name);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r36877 - in gnunet-qt/secushare: core core/gnunet core/identity core/social models,
gnunet <=