[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r36656 - in gnunet-qt/secushare: . core core/gnunet core/id
From: |
gnunet |
Subject: |
[GNUnet-SVN] r36656 - in gnunet-qt/secushare: . core core/gnunet core/identity core/social models preferences utils |
Date: |
Thu, 12 Nov 2015 19:30:41 +0100 |
Author: tg
Date: 2015-11-12 19:30:41 +0100 (Thu, 12 Nov 2015)
New Revision: 36656
Modified:
gnunet-qt/secushare/core/gnunet/gnunet.cpp
gnunet-qt/secushare/core/gnunet/gnunet.h
gnunet-qt/secushare/core/identity/identity.cpp
gnunet-qt/secushare/core/identity/identity.h
gnunet-qt/secushare/core/identity/identityService.cpp
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/main.cpp
gnunet-qt/secushare/models/IdentityModel.cpp
gnunet-qt/secushare/models/IdentityModel.h
gnunet-qt/secushare/models/PlacesModel.cpp
gnunet-qt/secushare/models/PlacesModel.h
gnunet-qt/secushare/models/models.cpp
gnunet-qt/secushare/models/models.h
gnunet-qt/secushare/preferences/preferences.cpp
gnunet-qt/secushare/preferences/preferences.h
gnunet-qt/secushare/psyc.cpp
gnunet-qt/secushare/psyc.h
gnunet-qt/secushare/utils/helpers.cpp
gnunet-qt/secushare/utils/helpers.h
gnunet-qt/secushare/utils/qrimageprovider.cpp
gnunet-qt/secushare/utils/qrimageprovider.h
Log:
indent
Modified: gnunet-qt/secushare/core/gnunet/gnunet.cpp
===================================================================
--- gnunet-qt/secushare/core/gnunet/gnunet.cpp 2015-11-12 18:30:37 UTC (rev
36655)
+++ gnunet-qt/secushare/core/gnunet/gnunet.cpp 2015-11-12 18:30:41 UTC (rev
36656)
@@ -39,15 +39,17 @@
* Static function.
* The first function executed when GNUNet is running.
*/
-void GNUNet::mainLoopCallback(void *cls, char *const *args, const char
*cfgfile,
- const struct GNUNET_CONFIGURATION_Handle *cfg)
+void
+GNUNet::mainLoopCallback (void *cls, char *const *args, const char *cfgfile,
+ const struct GNUNET_CONFIGURATION_Handle *cfg)
{
- //Retrive our main funtion
- GNUNet* gnunetInstance = (GNUNet*)cls;
- Q_ASSERT(gnunetInstance);
+ //Retrive our main funtion
+ GNUNet *gnunetInstance = (GNUNet *) cls;
- //Call our main loop
- gnunetInstance->mainLoop(args,cfgfile,cfg);
+ Q_ASSERT (gnunetInstance);
+
+ //Call our main loop
+ gnunetInstance->mainLoop (args, cfgfile, cfg);
}
@@ -55,19 +57,23 @@
* Static function
* Called to process our internal messages
*/
-void GNUNet::keepaliveTaskCallback (void *cls, const struct
GNUNET_SCHEDULER_TaskContext *tc)
+void
+GNUNet::keepaliveTaskCallback (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
{
- Q_UNUSED(tc);
+ Q_UNUSED (tc);
- //Retrive our main funtion
- Q_ASSERT(cls);
- GNUNet* gnunetInstance = (GNUNet*)cls;
+ //Retrive our main funtion
+ Q_ASSERT (cls);
+ GNUNet *gnunetInstance = (GNUNet *) cls;
- //Process the events
- gnunetInstance->processEvents();
+ //Process the events
+ gnunetInstance->processEvents ();
- //Call again in 500 millisecond.
- GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
(GNUNET_TIME_UNIT_MILLISECONDS, 500), &keepaliveTaskCallback, gnunetInstance);
+ //Call again in 500 millisecond.
+ GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
+ (GNUNET_TIME_UNIT_MILLISECONDS, 500),
+ &keepaliveTaskCallback, gnunetInstance);
}
@@ -76,19 +82,19 @@
***********************************/
-GNUNet::GNUNet(QObject *parent) :
- QObject(parent)
+GNUNet::GNUNet (QObject * parent):
+QObject (parent)
{
- m_connected = false;
- m_myPeer = new GNUNET_PeerIdentity;
+ m_connected = false;
+ m_myPeer = new GNUNET_PeerIdentity;
}
-GNUNet::~GNUNet()
+GNUNet::~GNUNet ()
{
- delete m_myPeer;
+ delete m_myPeer;
}
/**
@@ -95,68 +101,73 @@
* Start GNUnet
*/
-void GNUNet::start()
+void
+GNUNet::start ()
{
- m_identity = new IdentityService(this);
+ m_identity = new IdentityService (this);
- m_social = new SocialService(this);
+ m_social = new SocialService (this);
- static struct GNUNET_GETOPT_CommandLineOption options[] = {
- GNUNET_GETOPT_OPTION_END
- };
+ static struct GNUNET_GETOPT_CommandLineOption options[] = {
+ GNUNET_GETOPT_OPTION_END
+ };
- const char *const argv[] = {
- "secushare",
- NULL
- };
+ const char *const argv[] = {
+ "secushare",
+ NULL
+ };
- GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1,(char
*const*)argv,
- "secushare", "secushare helper", options,
- mainLoopCallback, this);
+ GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1,
+ (char *const *) argv, "secushare", "secushare helper",
+ options, mainLoopCallback, this);
}
/**
* It's the first function executed when GNUNet is running.
*/
-void GNUNet::mainLoop(char *const *args, const char *cfgfile,
- const struct GNUNET_CONFIGURATION_Handle *cfg)
+void
+GNUNet::mainLoop (char *const *args, const char *cfgfile,
+ const struct GNUNET_CONFIGURATION_Handle *cfg)
{
- Q_UNUSED(args);
- Q_UNUSED(cfgfile);
- Q_UNUSED(cfg);
+ Q_UNUSED (args);
+ Q_UNUSED (cfgfile);
+ Q_UNUSED (cfg);
- char *privateKeyFileName;
+ char *privateKeyFileName;
- //Create our configuration
- m_config = GNUNET_CONFIGURATION_create ();
- GNUNET_CONFIGURATION_load (m_config, cfgfile);
+ //Create our configuration
+ m_config = GNUNET_CONFIGURATION_create ();
+ GNUNET_CONFIGURATION_load (m_config, cfgfile);
- //Get my information
+ //Get my information
- //load private key
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_filename (m_config, "PEER",
"PRIVATE_KEY",
- &privateKeyFileName))
- {
- qWarning() << QString("Could not find option `GNUNETD:HOSTKEYFILE' in
configuration.\n");
- return;
- }
+ //load private key
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_filename (m_config, "PEER", "PRIVATE_KEY",
+ &privateKeyFileName))
+ {
+ qWarning () <<
+ QString
+ ("Could not find option `GNUNETD:HOSTKEYFILE' in configuration.\n");
+ return;
+ }
- //Get my own peer
- GNUNET_CRYPTO_get_peer_identity(m_config,m_myPeer);
+ //Get my own peer
+ GNUNET_CRYPTO_get_peer_identity (m_config, m_myPeer);
- char* str =
GNUNET_CRYPTO_eddsa_public_key_to_string(&m_myPeer->public_key);
- setMyPublicKeyStr(QString(str));
- GNUNET_free (str);
+ char *str = GNUNET_CRYPTO_eddsa_public_key_to_string (&m_myPeer->public_key);
+ setMyPublicKeyStr (QString (str));
+ GNUNET_free (str);
- //A update function to process our messages
- GNUNET_SCHEDULER_add_now ( keepaliveTaskCallback, this);
+ //A update function to process our messages
+ GNUNET_SCHEDULER_add_now (keepaliveTaskCallback, this);
- //Start arm
- startServices();
+
+ //Start arm
+ startServices ();
}
@@ -164,28 +175,33 @@
* Start the services such as filesharing
*/
-void GNUNet::startServices()
+void
+GNUNet::startServices ()
{
- m_identity->start(m_config);
+ m_identity->start (m_config);
- emit gnunetStarted();
+ emit gnunetStarted ();
}
-void GNUNet::identitySetSlot(){
- m_social->start(m_config);
+void
+GNUNet::identitySetSlot ()
+{
+ m_social->start (m_config);
}
/**
* Process our internal pending messages.
*/
-void GNUNet::processEvents()
+void
+GNUNet::processEvents ()
{
- QCoreApplication::processEvents();
+ QCoreApplication::processEvents ();
}
-GNUNET_PeerIdentity* GNUNet::myPeer() const
+GNUNET_PeerIdentity *
+GNUNet::myPeer () const const
{
- return m_myPeer;
+ return m_myPeer;
}
Modified: gnunet-qt/secushare/core/gnunet/gnunet.h
===================================================================
--- gnunet-qt/secushare/core/gnunet/gnunet.h 2015-11-12 18:30:37 UTC (rev
36655)
+++ gnunet-qt/secushare/core/gnunet/gnunet.h 2015-11-12 18:30:41 UTC (rev
36656)
@@ -29,60 +29,61 @@
class IdentityService;
+
class SocialService;
-class GNUNet : public QObject
+
+class GNUNet:public QObject
{
- Q_OBJECT
- Q_PROPERTY(IdentityService * identity READ identity CONSTANT)
- Q_PROPERTY(SocialService * social READ social CONSTANT)
+Q_OBJECT Q_PROPERTY (IdentityService * identity READ identity CONSTANT)
Q_PROPERTY (SocialService * social READ social CONSTANT) Q_PROPERTY
(GNUNET_CONFIGURATION_Handle * config READ config) Q_PROPERTY (bool connected
READ isConnected WRITE setConnected NOTIFY connectedChanged) Q_PROPERTY
(QString myPublicKeyStr READ myPublicKeyStr WRITE setMyPublicKeyStr NOTIFY
myPublicKeyStrChanged) public:
+ explicit GNUNet (QObject * parent =
+ 0);
+ ~GNUNet ();
- Q_PROPERTY(GNUNET_CONFIGURATION_Handle * config READ config)
+ IdentityService *identity () const
+ {
+ return m_identity;
+ }
- Q_PROPERTY(bool connected READ isConnected WRITE setConnected NOTIFY
connectedChanged)
+ SocialService *social () const
+ {
+ return m_social;
+ }
- Q_PROPERTY(QString myPublicKeyStr READ myPublicKeyStr WRITE
setMyPublicKeyStr NOTIFY myPublicKeyStrChanged)
+ GNUNET_CONFIGURATION_Handle *config () const
+ {
+ return m_config;
+ }
-public:
- explicit GNUNet(QObject *parent = 0);
- ~GNUNet();
- IdentityService* identity() const
- { return m_identity; }
+ bool isConnected () const
+ {
+ return m_connected;
+ }
- SocialService* social() const
- { return m_social; }
-
-
- GNUNET_CONFIGURATION_Handle* config() const
- { return m_config; }
-
-
-
- bool isConnected() const
- { return m_connected; }
-
- void setConnected(bool connected)
+ void setConnected (bool connected)
{
m_connected = connected;
- emit connectedChanged(m_connected);
+ emit connectedChanged (m_connected);
}
//Public Key Str
- QString myPublicKeyStr() const
- { return m_myPublicKeyStr; }
- void setMyPublicKeyStr(QString key)
+ QString myPublicKeyStr () const
{
+ return m_myPublicKeyStr;
+ }
+ void setMyPublicKeyStr (QString key)
+ {
m_myPublicKeyStr = key;
- emit myPublicKeyStrChanged(key);
+ emit myPublicKeyStrChanged (key);
}
- GNUNET_PeerIdentity* myPeer() const;
+ GNUNET_PeerIdentity *myPeer () const;
@@ -91,42 +92,46 @@
/**
Static Definitions
*/
- static void mainLoopCallback(void *cls, char *const *args, const char
*cfgfile,
- const struct GNUNET_CONFIGURATION_Handle *cfg);
+ static void mainLoopCallback (void *cls, char *const *args,
+ const char *cfgfile,
+ const struct GNUNET_CONFIGURATION_Handle *cfg);
- static void keepaliveTaskCallback (void *cls, const struct
GNUNET_SCHEDULER_TaskContext *tc);
+ static void keepaliveTaskCallback (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext
+ *tc);
public:
- void armConnectionStateChange(int connected);
+ void armConnectionStateChange (int connected);
signals:
- void gnunetStarted();
- void gnunetConnected();
- void connectedChanged(bool connected);
+ void gnunetStarted ();
- void myPublicKeyStrChanged(QString key);
+ void gnunetConnected ();
+ void connectedChanged (bool connected);
-public slots:
- void start();
+ void myPublicKeyStrChanged (QString key);
- void identitySetSlot();
-private slots:
- void startServices();
+ public slots:void start ();
+
+ void identitySetSlot ();
+
+ private slots:void startServices ();
+
private:
/**
* Pointer to GNUnet Identity Service.
*/
- IdentityService* m_identity;
+ IdentityService * m_identity;
/**
* Pointer to GNUnet Social Service.
*/
- SocialService* m_social;
+ SocialService *m_social;
@@ -146,7 +151,7 @@
* My peer.
*/
- struct GNUNET_PeerIdentity* m_myPeer;
+ struct GNUNET_PeerIdentity *m_myPeer;
/**
* My public key.
@@ -157,9 +162,11 @@
- void processEvents();
- void mainLoop(char *const*args, const char *cfgfile, const
GNUNET_CONFIGURATION_Handle *cfg);
+ void processEvents ();
+ void mainLoop (char *const *args, const char *cfgfile,
+ const GNUNET_CONFIGURATION_Handle * cfg);
+
};
#endif // GNUNET_H
Modified: gnunet-qt/secushare/core/identity/identity.cpp
===================================================================
--- gnunet-qt/secushare/core/identity/identity.cpp 2015-11-12 18:30:37 UTC
(rev 36655)
+++ gnunet-qt/secushare/core/identity/identity.cpp 2015-11-12 18:30:41 UTC
(rev 36656)
@@ -1,7 +1,7 @@
#include "identity.h"
-Identity::Identity(QString key, QObject *parent) :
- QObject(parent)
+Identity::Identity (QString key, QObject * parent):
+QObject (parent)
{
- m_key = key;
+ m_key = key;
}
Modified: gnunet-qt/secushare/core/identity/identity.h
===================================================================
--- gnunet-qt/secushare/core/identity/identity.h 2015-11-12 18:30:37 UTC
(rev 36655)
+++ gnunet-qt/secushare/core/identity/identity.h 2015-11-12 18:30:41 UTC
(rev 36656)
@@ -4,56 +4,63 @@
#include <QObject>
#include "core/gnunet/gnunet_includes.h"
-class Identity : public QObject
+class Identity:public QObject
{
- Q_OBJECT
- Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
- Q_PROPERTY(QString url READ url CONSTANT)
+Q_OBJECT Q_PROPERTY (QString name READ name WRITE setName NOTIFY nameChanged)
Q_PROPERTY (QString url READ url CONSTANT) public:
+ explicit Identity (QString key, QObject * parent =
+ 0);
-public:
- explicit Identity(QString key, QObject *parent = 0);
+ //Index
+ int getIndex () const
+ {
+ return m_index;
+ }
+ void setIndex (int index)
+ {
+ m_index = index;
+ }
- //Index
- int getIndex() const
- { return m_index; }
- void setIndex(int index)
- {
- m_index = index;
- }
+ QString name ()
+ {
+ return m_name;
+ }
+ void setName (QString name)
+ {
+ m_name = name;
+ emit nameChanged (name);
- QString name(){
- return m_name;
- }
- void setName(QString name){
- m_name = name;
- emit nameChanged(name);
- emit modifiedSignal(m_index);
- }
+ emit modifiedSignal (m_index);
+ }
- QString url(){
- return QString("GNUNET://GNS/%1/").arg(m_key);
- }
+ QString url ()
+ {
+ return QString ("GNUNET://GNS/%1/").arg (m_key);
+ }
- GNUNET_IDENTITY_Ego* ego(){
- return m_ego;
- }
- void setEgo(GNUNET_IDENTITY_Ego* ego){
- m_ego = ego;
- }
+ GNUNET_IDENTITY_Ego *ego ()
+ {
+ return m_ego;
+ }
+ void setEgo (GNUNET_IDENTITY_Ego * ego)
+ {
+ m_ego = ego;
+ }
private:
- int m_index;
- QString m_name;
- QString m_key;
- GNUNET_IDENTITY_Ego * m_ego;
+ int m_index;
+ QString m_name;
+
+ QString m_key;
+
+ GNUNET_IDENTITY_Ego *m_ego;
+
signals:
- void modifiedSignal(int index);
- void nameChanged(QString name);
+ void modifiedSignal (int index);
-public slots:
+ void nameChanged (QString name);
-};
+public slots:};
#endif // IDENTITY_H
Modified: gnunet-qt/secushare/core/identity/identityService.cpp
===================================================================
--- gnunet-qt/secushare/core/identity/identityService.cpp 2015-11-12
18:30:37 UTC (rev 36655)
+++ gnunet-qt/secushare/core/identity/identityService.cpp 2015-11-12
18:30:41 UTC (rev 36656)
@@ -6,8 +6,8 @@
#include "core/identity/identity.h"
-IdentityService::IdentityService(QObject *parent) :
- QObject(parent)
+IdentityService::IdentityService (QObject * parent):
+QObject (parent)
{
}
@@ -16,17 +16,16 @@
* @brief Identity::start
* @param config
*/
-void IdentityService::start(struct GNUNET_CONFIGURATION_Handle *config)
+void
+IdentityService::start (struct GNUNET_CONFIGURATION_Handle *config)
{
- this->m_config = config;
+ this->m_config = config;
- QObject::connect(this, &IdentityService::createEgoSignal, this,
- &IdentityService::createEgoSlot, Qt::QueuedConnection);
+ QObject::connect (this, &IdentityService::createEgoSignal, this,
+ &IdentityService::createEgoSlot, Qt::QueuedConnection);
- m_identityHandle = GNUNET_IDENTITY_connect (config,
- &addEgoCallback,
- this);
+ m_identityHandle = GNUNET_IDENTITY_connect (config, &addEgoCallback, this);
}
@@ -40,15 +39,14 @@
* @param name name of the namespace to add
*/
void
-IdentityService::addEgoCallback (void *cls,
- struct GNUNET_IDENTITY_Ego *ego,
- void **ego_ctx,
- const char *name)
+IdentityService::addEgoCallback (void *cls, struct GNUNET_IDENTITY_Ego *ego,
+ void **ego_ctx, const char *name)
{
- IdentityService* classPointer = (IdentityService*)cls;
- classPointer->addEgo(ego,ego_ctx,name);
+ IdentityService *classPointer = (IdentityService *) cls;
+ classPointer->addEgo (ego, ego_ctx, name);
+
}
/**
@@ -58,66 +56,66 @@
* @param emsg error message (NULL on success)
*/
void
-IdentityService::operationFinished (void *cls,
- const char *emsg)
+IdentityService::operationFinished (void *cls, const char *emsg)
{
- Q_UNUSED(cls);
- Q_UNUSED(emsg);
- //NOP
+ Q_UNUSED (cls);
+ Q_UNUSED (emsg);
+ //NOP
}
void
-IdentityService::createEgo(QString ego)
+IdentityService::createEgo (QString ego)
{
- emit createEgoSignal(ego);
+ emit createEgoSignal (ego);
}
void
-IdentityService::createEgoSlot(QString ego)
+IdentityService::createEgoSlot (QString ego)
{
- QByteArray byteArray = ego.toUtf8();
- const char* cString = byteArray.constData();
+ QByteArray byteArray = ego.toUtf8 ();
- GNUNET_IDENTITY_create (m_identityHandle,
- cString,
- &operationFinished,
- NULL);
+ const char *cString = byteArray.constData ();
+
+ GNUNET_IDENTITY_create (m_identityHandle, cString, &operationFinished, NULL);
}
void
-IdentityService::addEgo(struct GNUNET_IDENTITY_Ego *ego,
- void **ego_ctx,
- const char *name)
+IdentityService::addEgo (struct GNUNET_IDENTITY_Ego *ego, void **ego_ctx,
+ const char *name)
{
- Identity* identity;
- struct GNUNET_CRYPTO_EcdsaPublicKey pub;
+ Identity *identity;
- if (NULL == ego)
- return; /* nothing to be done */
+ struct GNUNET_CRYPTO_EcdsaPublicKey pub;
- identity = (Identity*)*ego_ctx;
+ if (NULL == ego)
+ return; /* nothing to be done */
- if(identity == NULL) // Its a new identity
- {
- GNUNET_IDENTITY_ego_get_public_key (ego, &pub);
- char* id = GNUNET_CRYPTO_ecdsa_public_key_to_string (&pub);
- QString strId = QString::fromLatin1(id);
- QString strName = QString::fromLatin1(name);
+ identity = (Identity *) * ego_ctx;
- identity = theApp->models()->identityModel()->add(strId,strName,ego);
+ if (identity == NULL) // Its a new identity
+ {
+ GNUNET_IDENTITY_ego_get_public_key (ego, &pub);
+ char *id = GNUNET_CRYPTO_ecdsa_public_key_to_string (&pub);
- *ego_ctx = identity;
- }
- else if (NULL == name) // Delete
- {
+ QString strId = QString::fromLatin1 (id);
- }
- else // Rename
- {
- QString strName = QString::fromLatin1(name);
- identity->setName(strName);
- }
+ QString strName = QString::fromLatin1 (name);
+
+ identity = theApp->models ()->identityModel ()->add (strId, strName, ego);
+
+ *ego_ctx = identity;
+ }
+ else if (NULL == name) // Delete
+ {
+
+ }
+ else // Rename
+ {
+ QString strName = QString::fromLatin1 (name);
+
+ identity->setName (strName);
+ }
}
Modified: gnunet-qt/secushare/core/identity/identityService.h
===================================================================
--- gnunet-qt/secushare/core/identity/identityService.h 2015-11-12 18:30:37 UTC
(rev 36655)
+++ gnunet-qt/secushare/core/identity/identityService.h 2015-11-12 18:30:41 UTC
(rev 36656)
@@ -4,29 +4,27 @@
#include <QObject>
#include "core/gnunet/gnunet_includes.h"
-class IdentityService : public QObject
+class IdentityService:public QObject
{
- Q_OBJECT
-public:
- explicit IdentityService(QObject *parent = 0);
+Q_OBJECT public:
+ explicit IdentityService (QObject * parent = 0);
- void start(GNUNET_CONFIGURATION_Handle *config);
- static void addEgoCallback(void *cls, struct GNUNET_IDENTITY_Ego *ego,
void **ego_ctx, const char *name);
+ void start (GNUNET_CONFIGURATION_Handle * config);
+ static void addEgoCallback (void *cls, struct GNUNET_IDENTITY_Ego *ego,
+ void **ego_ctx, const char *name);
- void addEgo(GNUNET_IDENTITY_Ego *ego, void **ego_ctx, const char *name);
- Q_INVOKABLE void createEgo(QString ego);
- static void operationFinished(void *cls, const char *emsg);
-signals:
- void createEgoSignal(QString ego);
-public slots:
- void createEgoSlot(QString ego);
+ void addEgo (GNUNET_IDENTITY_Ego * ego, void **ego_ctx, const char *name);
+ Q_INVOKABLE void createEgo (QString ego);
+ static void operationFinished (void *cls, const char *emsg);
+ signals:void createEgoSignal (QString ego);
+ public slots:void createEgoSlot (QString ego);
private:
- struct GNUNET_CONFIGURATION_Handle *m_config;
+ struct GNUNET_CONFIGURATION_Handle *m_config;
/**
* Handle to IDENTITY service.
*/
- struct GNUNET_IDENTITY_Handle *m_identityHandle;
+ struct GNUNET_IDENTITY_Handle *m_identityHandle;
};
Modified: gnunet-qt/secushare/core/psyccore.cpp
===================================================================
--- gnunet-qt/secushare/core/psyccore.cpp 2015-11-12 18:30:37 UTC (rev
36655)
+++ gnunet-qt/secushare/core/psyccore.cpp 2015-11-12 18:30:41 UTC (rev
36656)
@@ -13,22 +13,22 @@
/* Static member variables */
-PsycCore* theApp;
+PsycCore *theApp;
-PsycCore::PsycCore(QObject *parent) :
- QObject(parent)
+PsycCore::PsycCore (QObject * parent):
+QObject (parent)
{
- theApp = this;
- m_models = new Models(this);
+ theApp = this;
+ m_models = new Models (this);
- m_helpers = new Helpers(this);
+ m_helpers = new Helpers (this);
- m_qrProvider = new QrImageProvider();
+ m_qrProvider = new QrImageProvider ();
- m_identity = NULL;
+ m_identity = NULL;
- //Finally start gnunet
- startGNUNet();
+ //Finally start gnunet
+ startGNUNet ();
}
@@ -35,71 +35,79 @@
/**
* @brief CangoteCore::startGNUNet Start the GNUNet part. It need to run in a
different thread
*/
-void PsycCore::startGNUNet()
+void
+PsycCore::startGNUNet ()
{
- //Create the Gnunet object
- m_gnunet = new GNUNet();
+ //Create the Gnunet object
+ m_gnunet = new GNUNet ();
- //New thread where the Gnunet will be run on.
- m_gnunetThread = new QThread();
+ //New thread where the Gnunet will be run on.
+ m_gnunetThread = new QThread ();
- m_gnunet->moveToThread(m_gnunetThread);
+ m_gnunet->moveToThread (m_gnunetThread);
- // Call the start function after our thread is ready to run
- connect(m_gnunetThread,
- &QThread::started,
- m_gnunet,
- &GNUNet::start);
+ // Call the start function after our thread is ready to run
+ connect (m_gnunetThread, &QThread::started, m_gnunet, &GNUNet::start);
- m_gnunetThread->start();
+ m_gnunetThread->start ();
- connect(m_gnunet, &GNUNet::connectedChanged, this,
&PsycCore::setConnected, Qt::QueuedConnection);
+ connect (m_gnunet, &GNUNet::connectedChanged, this, &PsycCore::setConnected,
+ Qt::QueuedConnection);
- connect(this, &PsycCore::setIdentitySignal, m_gnunet,
&GNUNet::identitySetSlot, Qt::QueuedConnection);
+ connect (this, &PsycCore::setIdentitySignal, m_gnunet,
+ &GNUNet::identitySetSlot, Qt::QueuedConnection);
}
-void PsycCore::setupTray()
+void
+PsycCore::setupTray ()
{
- // create the menu
- m_trayMenu = new QMenu( QCoreApplication::instance()->applicationName() );
- // add a horizontal line to the menu
+ // create the menu
+ m_trayMenu = new QMenu (QCoreApplication::instance ()->applicationName ());
+ // add a horizontal line to the menu
- m_trayMenu->addSeparator();
- m_trayCloseAction = m_trayMenu->addAction("Close");
- connect(m_trayCloseAction, &QAction::triggered, this, &PsycCore::close);
+ m_trayMenu->addSeparator ();
+ m_trayCloseAction = m_trayMenu->addAction ("Close");
+ connect (m_trayCloseAction, &QAction::triggered, this, &PsycCore::close);
- m_tray = new QSystemTrayIcon(QIcon(":/assets/icon.ico"),theWindow); //Same
as above
- m_tray->setContextMenu(m_trayMenu);
- m_tray->setVisible(true);
+ m_tray = new QSystemTrayIcon (QIcon (":/assets/icon.ico"), theWindow);
//Same as above
+ m_tray->setContextMenu (m_trayMenu);
+ m_tray->setVisible (true);
- QObject::connect(m_tray, &QSystemTrayIcon::activated,this,
&PsycCore::trayActivated );
+ QObject::connect (m_tray, &QSystemTrayIcon::activated, this,
+ &PsycCore::trayActivated);
}
-void PsycCore::trayActivated(QSystemTrayIcon::ActivationReason reason)
+void
+PsycCore::trayActivated (QSystemTrayIcon::ActivationReason reason)
{
- if(reason == QSystemTrayIcon::DoubleClick){
- if(!theWindow->isVisible()){
+ if (reason == QSystemTrayIcon::DoubleClick)
+ {
+ if (!theWindow->isVisible ())
+ {
- theWindow->show();
+ theWindow->show ();
- }else{
- onClose();
- }
}
+ else
+ {
+ onClose ();
+ }
+ }
}
-void PsycCore::setConnected(bool connected)
+void
+PsycCore::setConnected (bool connected)
{
- m_connected = connected;
+ m_connected = connected;
- emit connectedChanged(m_connected);
+ emit connectedChanged (m_connected);
}
@@ -107,9 +115,10 @@
* @brief PsycCore::onClose
* Recivied close signal
*/
-void PsycCore::onClose()
+void
+PsycCore::onClose ()
{
- theWindow->hide();
+ theWindow->hide ();
}
@@ -117,16 +126,19 @@
* @brief PsycCore::close
* Actually close the applciation
*/
-void PsycCore::close(){
- //setAlive(false);
- QApplication::quit();
+void
+PsycCore::close ()
+{
+ //setAlive(false);
+ QApplication::quit ();
}
-void PsycCore::setIdentity(Identity* identity)
+void
+PsycCore::setIdentity (Identity * identity)
{
- m_identity = identity;
- emit setIdentitySignal();
+ m_identity = identity;
+ emit setIdentitySignal ();
}
@@ -135,15 +147,17 @@
* @brief PsycCore::setTrayMessage , will only show if the Window is hidden
* @param message
*/
-void PsycCore::setTrayMessage(QString room, QString message)
+void
+PsycCore::setTrayMessage (QString room, QString message)
{
- if(!theWindow->isVisible()){
+ if (!theWindow->isVisible ())
+ {
- m_tray->showMessage(room, message);
+ m_tray->showMessage (room, message);
- }
+ }
}
Modified: gnunet-qt/secushare/core/psyccore.h
===================================================================
--- gnunet-qt/secushare/core/psyccore.h 2015-11-12 18:30:37 UTC (rev 36655)
+++ gnunet-qt/secushare/core/psyccore.h 2015-11-12 18:30:41 UTC (rev 36656)
@@ -6,84 +6,92 @@
#include <QAction>
class GNUNet;
+
class Models;
+
class Helpers;
+
class Identity;
+
class QrImageProvider;
-class PsycCore : public QObject
+
+class PsycCore:public QObject
{
- Q_OBJECT
- Q_PROPERTY(Models * models READ models CONSTANT)
- Q_PROPERTY(GNUNet * gnunet READ gnunet CONSTANT)
- Q_PROPERTY(Helpers * helpers READ helpers CONSTANT)
- Q_PROPERTY(QrImageProvider* qrProvider READ qrProvider CONSTANT)
- Q_PROPERTY(Identity * identity READ identity WRITE setIdentity)
- Q_PROPERTY(bool connected READ isConnected WRITE setConnected NOTIFY
connectedChanged)
+Q_OBJECT Q_PROPERTY (Models * models READ models CONSTANT) Q_PROPERTY (GNUNet
* gnunet READ gnunet CONSTANT) Q_PROPERTY (Helpers * helpers READ helpers
CONSTANT) Q_PROPERTY (QrImageProvider * qrProvider READ qrProvider CONSTANT)
Q_PROPERTY (Identity * identity READ identity WRITE setIdentity) Q_PROPERTY
(bool connected READ isConnected WRITE setConnected NOTIFY connectedChanged)
public:
+ explicit PsycCore (QObject * parent =
+ 0);
-public:
- explicit PsycCore(QObject *parent = 0);
+ GNUNet *gnunet () const
+ {
+ return m_gnunet;
+ }
- GNUNet* gnunet() const
- { return m_gnunet; }
+ Models *models () const
+ {
+ return m_models;
+ }
- Models* models() const
- { return m_models; }
+ Helpers *helpers () const
+ {
+ return m_helpers;
+ }
- Helpers* helpers() const
- { return m_helpers; }
+ QrImageProvider *qrProvider () const
+ {
+ return m_qrProvider;
+ }
- QrImageProvider* qrProvider() const
- { return m_qrProvider; }
+ Identity *identity () const
+ {
+ return m_identity;
+ }
- Identity* identity() const
- { return m_identity; }
+ Q_INVOKABLE void setIdentity (Identity * identity);
- Q_INVOKABLE void setIdentity(Identity* identity);
+ void setupTray ();
+ Q_INVOKABLE void onClose ();
- void setupTray();
- Q_INVOKABLE void onClose();
+ void setConnected (bool connected);
- void setConnected(bool connected);
+ bool isConnected () const
+ {
+ return m_connected;
+ }
- bool isConnected() const
- { return m_connected; }
-
private:
- Models* m_models;
+ Models * m_models;
- Helpers* m_helpers;
+ Helpers *m_helpers;
- QrImageProvider* m_qrProvider;
+ QrImageProvider *m_qrProvider;
- Identity* m_identity;
+ Identity *m_identity;
- GNUNet* m_gnunet;
- QThread *m_gnunetThread;
+ GNUNet *m_gnunet;
+ QThread *m_gnunetThread;
- QMenu* m_trayMenu;
- QSystemTrayIcon* m_tray;
- QAction* m_trayCloseAction;
+ QMenu *m_trayMenu;
+ QSystemTrayIcon *m_tray;
+ QAction *m_trayCloseAction;
- //Store if the GNUNet service is connected
- bool m_connected;
+ //Store if the GNUNet service is connected
+ bool m_connected;
- void close();
- void startGNUNet();
-signals:
- void connectedChanged(bool connected);
- void setIdentitySignal();
+ void close ();
+ void startGNUNet ();
+ signals:void connectedChanged (bool connected);
+ void setIdentitySignal ();
-public slots:
- void trayActivated(QSystemTrayIcon::ActivationReason reason);
- void setTrayMessage(QString room, QString message);
+ public slots:void trayActivated (QSystemTrayIcon::ActivationReason reason);
+ void setTrayMessage (QString room, QString message);
};
//Those are the externals visible to the whole application ( globals)
-extern PsycCore* theApp;
+extern PsycCore *theApp;
#endif // PSYCCORE_H
Modified: gnunet-qt/secushare/core/social/place.cpp
===================================================================
--- gnunet-qt/secushare/core/social/place.cpp 2015-11-12 18:30:37 UTC (rev
36655)
+++ gnunet-qt/secushare/core/social/place.cpp 2015-11-12 18:30:41 UTC (rev
36656)
@@ -11,30 +11,31 @@
* @param key
* @param parent
*/
-Place::Place(QString key, QObject *parent) :
- QObject(parent)
+Place::Place (QString key, QObject * parent):
+QObject (parent)
{
- m_key = key;
- m_status = "No status";
- m_name = "No name";
- m_type = "group";//thread;group;contact
- m_isHost = false;
+ m_key = key;
+ m_status = "No status";
+ m_name = "No name";
+ m_type = "group"; //thread;group;contact
+ m_isHost = false;
- connect(this,&Place::addConversationSignal,
- this,&Place::addConversationSlot, Qt::QueuedConnection);
+ connect (this, &Place::addConversationSignal, this,
+ &Place::addConversationSlot, Qt::QueuedConnection);
- connect(this,&Place::setTrayMessageSignal,
- theApp,&PsycCore::setTrayMessage, Qt::QueuedConnection);
+ connect (this, &Place::setTrayMessageSignal, theApp,
+ &PsycCore::setTrayMessage, Qt::QueuedConnection);
}
/**
* @brief Place::copyToClipboard , copy the key to clipboard
*/
-void Place::copyToClipboard()
+void
+Place::copyToClipboard ()
{
- QClipboard *clipboard = QApplication::clipboard();
+ QClipboard *clipboard = QApplication::clipboard ();
- clipboard->setText(m_key);
+ clipboard->setText (m_key);
}
/**
@@ -41,16 +42,17 @@
* @brief Place::talk , talk in the room
* @param text
*/
-void Place::talk(QString text)
+void
+Place::talk (QString text)
{
- if(m_isHost)
- {
- emit hostTalkSignal(this,text);
- }
- else
- {
- emit guestTalkSignal(this,text);
- }
+ if (m_isHost)
+ {
+ emit hostTalkSignal (this, text);
+ }
+ else
+ {
+ emit guestTalkSignal (this, text);
+ }
}
/**
@@ -57,13 +59,14 @@
* @brief Place::addConversation , signal to the slot to add the conversation
to place
* @param text
*/
-void Place::addConversation(QString text)
+void
+Place::addConversation (QString text)
{
- emit addConversationSignal(text);
+ emit addConversationSignal (text);
- //Set tray message
- if(text.length() > 1)
- emit setTrayMessageSignal(m_key,text);
+ //Set tray message
+ if (text.length () > 1)
+ emit setTrayMessageSignal (m_key, text);
}
@@ -71,16 +74,17 @@
* @brief Place::addConversationSlot , Slot to add the conversation to place
* @param text
*/
-void Place::addConversationSlot(QString text)
+void
+Place::addConversationSlot (QString text)
{
- if(text.length() < 1)
- return;
+ if (text.length () < 1)
+ return;
- //Add Ttimestamp befor text
- QString current = QTime::currentTime().toString("hh:mm:ss ap");
+ //Add Ttimestamp befor text
+ QString current = QTime::currentTime ().toString ("hh:mm:ss ap");
- m_content += "<small>("+ current + ")</small> : " + text + "<br/>";
+ m_content += "<small>(" + current + ")</small> : " + text + "<br/>";
- emit contentChanged(m_content);
+ emit contentChanged (m_content);
}
Modified: gnunet-qt/secushare/core/social/place.h
===================================================================
--- gnunet-qt/secushare/core/social/place.h 2015-11-12 18:30:37 UTC (rev
36655)
+++ gnunet-qt/secushare/core/social/place.h 2015-11-12 18:30:41 UTC (rev
36656)
@@ -3,152 +3,183 @@
#include <QObject>
-class Place : public QObject
+class Place:public QObject
{
- Q_OBJECT
- Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
- Q_PROPERTY(QString content READ content NOTIFY contentChanged)
-public:
- explicit Place(QString key, QObject *parent = 0);
+Q_OBJECT Q_PROPERTY (QString name READ name WRITE setName NOTIFY nameChanged)
Q_PROPERTY (QString content READ content NOTIFY contentChanged) public:
+ explicit Place (QString key, QObject * parent =
+ 0);
- //Index
- int getIndex() const
- { return m_index; }
- void setIndex(int index)
- {
- m_index = index;
- }
+ //Index
+ int getIndex () const
+ {
+ return m_index;
+ }
+ void setIndex (int index)
+ {
+ m_index = index;
+ }
- //Name
- QString name() const
- { return m_name; }
- void setName(QString name)
- {
- m_name = name;
- emit nameChanged(name);
- }
+ //Name
+ QString name () const
+ {
+ return m_name;
+ }
+ void setName (QString name)
+ {
+ m_name = name;
+ emit nameChanged (name);
+ }
- //Type
- QString type() const
- { return m_type; }
- void setType(QString type)
- {
- m_type = type;
- emit typeChanged(type);
- }
+ //Type
+ QString type () const
+ {
+ return m_type;
+ }
+ void setType (QString type)
+ {
+ m_type = type;
+ emit typeChanged (type);
+ }
- //Status
- QString status() const
- { return m_status; }
- void setStatus(QString status)
- {
- m_status = status;
- emit statusChanged(status);
- }
+ //Status
+ QString status () const
+ {
+ return m_status;
+ }
+ void setStatus (QString status)
+ {
+ m_status = status;
+ emit statusChanged (status);
+ }
- //Social Guest
- struct GNUNET_SOCIAL_Guest* socialGuest() const
- { return m_gst; }
- void setSocialGuest(struct GNUNET_SOCIAL_Guest* guest)
- {
- m_gst = guest;
- }
+ //Social Guest
+ struct GNUNET_SOCIAL_Guest *socialGuest () const
+ {
+ return m_gst;
+ }
+ void setSocialGuest (struct GNUNET_SOCIAL_Guest *guest)
+ {
+ m_gst = guest;
+ }
- //Content
- QString content() const
- { return m_content; }
+ //Content
+ QString content () const
+ {
+ return m_content;
+ }
- //Slicer
- struct GNUNET_SOCIAL_Slicer* slicer() const
- { return m_slicer; }
- void setSlicer(struct GNUNET_SOCIAL_Slicer* slicer)
- {
- m_slicer = slicer;
- }
+ //Slicer
+ struct GNUNET_SOCIAL_Slicer *slicer () const
+ {
+ return m_slicer;
+ }
+ void setSlicer (struct GNUNET_SOCIAL_Slicer *slicer)
+ {
+ m_slicer = slicer;
+ }
- //Host
- struct GNUNET_SOCIAL_Host* host() const
- { return m_hst; }
- void setHost(struct GNUNET_SOCIAL_Host* host)
- {
- m_hst = host;
- m_isHost = true;
- }
+ //Host
+ struct GNUNET_SOCIAL_Host *host () const
+ {
+ return m_hst;
+ }
+ void setHost (struct GNUNET_SOCIAL_Host *host)
+ {
+ m_hst = host;
+ m_isHost = true;
+ }
- //Is Host ?
- bool isHost() const
- { return m_isHost; }
+ //Is Host ?
+ bool isHost () const
+ {
+ return m_isHost;
+ }
- //Private Key
- struct GNUNET_CRYPTO_EddsaPrivateKey* privateKey() const
- { return m_placeKey; }
+ //Private Key
+ struct GNUNET_CRYPTO_EddsaPrivateKey *privateKey () const
+ {
+ return m_placeKey;
+ }
- void setPrivateKey(struct GNUNET_CRYPTO_EddsaPrivateKey* key)
- {
- m_placeKey = key;
- }
+ void setPrivateKey (struct GNUNET_CRYPTO_EddsaPrivateKey *key)
+ {
+ m_placeKey = key;
+ }
- //Public Key
- struct GNUNET_CRYPTO_EddsaPublicKey* publicKey() const
- { return m_placePubKey; }
- void setPublicKey(struct GNUNET_CRYPTO_EddsaPublicKey* key)
- {
- m_placePubKey = key;
- }
+ //Public Key
+ struct GNUNET_CRYPTO_EddsaPublicKey *publicKey () const
+ {
+ return m_placePubKey;
+ }
+ void setPublicKey (struct GNUNET_CRYPTO_EddsaPublicKey *key)
+ {
+ m_placePubKey = key;
+ }
- Q_INVOKABLE void copyToClipboard();
- Q_INVOKABLE void talk(QString text);
+ Q_INVOKABLE void copyToClipboard ();
- void addConversation(QString text);
+ Q_INVOKABLE void talk (QString text);
+ void addConversation (QString text);
+
private:
- int m_index;
- QString m_name;
- QString m_type;
- QString m_status;
+ int m_index;
+ QString m_name;
- QString m_content;
+ QString m_type;
- struct GNUNET_CRYPTO_EddsaPrivateKey *m_placeKey;
- QString m_key;
- //For guests
- struct GNUNET_SOCIAL_Guest * m_gst;
+ QString m_status;
- //For hosts
- bool m_isHost;
- struct GNUNET_SOCIAL_Slicer* m_slicer;
- struct GNUNET_SOCIAL_Host *m_hst;
+ QString m_content;
- struct GNUNET_CRYPTO_EddsaPublicKey* m_placePubKey;
+ struct GNUNET_CRYPTO_EddsaPrivateKey *m_placeKey;
- //The peer got his inscrition approved ?
- bool m_approved;
+ QString m_key;
+ //For guests
+ struct GNUNET_SOCIAL_Guest *m_gst;
+
+ //For hosts
+ bool m_isHost;
+
+ struct GNUNET_SOCIAL_Slicer *m_slicer;
+
+ struct GNUNET_SOCIAL_Host *m_hst;
+
+
+ struct GNUNET_CRYPTO_EddsaPublicKey *m_placePubKey;
+
+ //The peer got his inscrition approved ?
+ bool m_approved;
+
signals:
- void modifiedSignal(int index);
- void nameChanged(QString name);
- void typeChanged(QString type);
- void statusChanged(QString status);
+ void modifiedSignal (int index);
- void contentChanged(QString content);
+ void nameChanged (QString name);
- void guestTalkSignal (Place* place, QString text);
- void hostTalkSignal (Place* place, QString text);
+ void typeChanged (QString type);
- void addConversationSignal(QString text);
- void setTrayMessageSignal (QString room, QString text);
+ void statusChanged (QString status);
+ void contentChanged (QString content);
-public slots:
+ void guestTalkSignal (Place * place, QString text);
- void addConversationSlot(QString text);
+ void hostTalkSignal (Place * place, QString text);
+ void addConversationSignal (QString text);
+
+ void setTrayMessageSignal (QString room, QString text);
+
+
+ public slots:void addConversationSlot (QString text);
+
};
#endif // PLACE_H
Modified: gnunet-qt/secushare/core/social/socialservice.cpp
===================================================================
--- gnunet-qt/secushare/core/social/socialservice.cpp 2015-11-12 18:30:37 UTC
(rev 36655)
+++ gnunet-qt/secushare/core/social/socialservice.cpp 2015-11-12 18:30:41 UTC
(rev 36656)
@@ -15,18 +15,18 @@
#define DATA2ARG(data) data, sizeof (data)
-SocialService::SocialService(QObject *parent) :
- QObject(parent)
+SocialService::SocialService (QObject * parent):
+QObject (parent)
{
-
- //Connect slots
- connect(this,&SocialService::createPlaceSignal,
- this,&SocialService::createPlaceSlot, Qt::QueuedConnection);
- connect(this,&SocialService::enterRoomSignal,
- this,&SocialService::enterRoomSlot, Qt::QueuedConnection);
-
+ //Connect slots
+ connect (this, &SocialService::createPlaceSignal, this,
+ &SocialService::createPlaceSlot, Qt::QueuedConnection);
+
+ connect (this, &SocialService::enterRoomSignal, this,
+ &SocialService::enterRoomSlot, Qt::QueuedConnection);
+
}
@@ -36,89 +36,95 @@
* @brief Should be called when the GNUnet service is connected to start
everything
* @param config
*/
-void SocialService::start(struct GNUNET_CONFIGURATION_Handle *config)
+void
+SocialService::start (struct GNUNET_CONFIGURATION_Handle *config)
{
- this->m_config = config;
+ this->m_config = config;
- //Grab selected identity at home screen
- Identity* iden = theApp->identity();
- m_hostEgo = iden->ego();
+ //Grab selected identity at home screen
+ Identity *iden = theApp->identity ();
- //Load rooms
- theApp->models()->placesModel()->load();
+ m_hostEgo = iden->ego ();
+ //Load rooms
+ theApp->models ()->placesModel ()->load ();
+
}
-void SocialService::createPlace(QString name)
+void
+SocialService::createPlace (QString name)
{
- emit createPlaceSignal(name);
+ emit createPlaceSignal (name);
}
-void SocialService::createPlaceSlot(QString name)
+void
+SocialService::createPlaceSlot (QString name)
{
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Creating a New Place.\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Creating a New Place.\n");
- QString filename = thePrefs->getFolder() + "/places/" + name + ".private";
+ QString filename = thePrefs->getFolder () + "/places/" + name + ".private";
- GNUNET_CRYPTO_EddsaPrivateKey *placeKey =
GNUNET_CRYPTO_eddsa_key_create_from_file(filename.toStdString().c_str());
- GNUNET_CRYPTO_EddsaPublicKey *placePubKey= new
GNUNET_CRYPTO_EddsaPublicKey;
+ GNUNET_CRYPTO_EddsaPrivateKey *placeKey =
+ GNUNET_CRYPTO_eddsa_key_create_from_file (filename.toStdString ().
+ c_str ());
+ GNUNET_CRYPTO_EddsaPublicKey *placePubKey = new GNUNET_CRYPTO_EddsaPublicKey;
- GNUNET_CRYPTO_eddsa_key_get_public (placeKey, placePubKey);
+ GNUNET_CRYPTO_eddsa_key_get_public (placeKey, placePubKey);
- char* id = GNUNET_CRYPTO_eddsa_public_key_to_string (placePubKey);
- QString strId = QString::fromLatin1(id);
+ char *id = GNUNET_CRYPTO_eddsa_public_key_to_string (placePubKey);
- Place* newPlace = theApp->models()->placesModel()->add(strId);
+ QString strId = QString::fromLatin1 (id);
- newPlace->setName(strId);
- newPlace->setPrivateKey(placeKey);
- newPlace->setPublicKey(placePubKey);
+ Place *newPlace = theApp->models ()->placesModel ()->add (strId);
- GNUNET_SOCIAL_Slicer* slicer = GNUNET_SOCIAL_slicer_create ();
- GNUNET_SOCIAL_slicer_method_add (slicer, "",
- &hostRecvMethodCallback,
- &hostRecvModifierCallback,
- &hostRecvDataCallback,
- &hostRecvEomCallback,
- newPlace);
- newPlace->setSlicer(slicer);
+ newPlace->setName (strId);
+ newPlace->setPrivateKey (placeKey);
+ newPlace->setPublicKey (placePubKey);
- GNUNET_SOCIAL_Host *
- host = GNUNET_SOCIAL_host_enter (m_config, m_hostEgo, placeKey,
- GNUNET_PSYC_CHANNEL_PRIVATE,
- slicer,
- &hostEnteredCallback,
- &hostAnswerDoorCallback,
- &hostFarewellCallback,
- newPlace);
- newPlace->setHost(host);
+ GNUNET_SOCIAL_Slicer *slicer = GNUNET_SOCIAL_slicer_create ();
- connect(newPlace,&Place::hostTalkSignal,
- this,&SocialService::hostTalk, Qt::QueuedConnection);
+ GNUNET_SOCIAL_slicer_method_add (slicer, "", &hostRecvMethodCallback,
+ &hostRecvModifierCallback,
+ &hostRecvDataCallback, &hostRecvEomCallback,
+ newPlace);
+ newPlace->setSlicer (slicer);
- //Save hosts
- theApp->models()->placesModel()->save();
+ GNUNET_SOCIAL_Host *host =
+ GNUNET_SOCIAL_host_enter (m_config, m_hostEgo, placeKey,
+ GNUNET_PSYC_CHANNEL_PRIVATE,
+ slicer,
+ &hostEnteredCallback,
+ &hostAnswerDoorCallback,
+ &hostFarewellCallback,
+ newPlace);
+ newPlace->setHost (host);
+
+ connect (newPlace, &Place::hostTalkSignal, this, &SocialService::hostTalk,
+ Qt::QueuedConnection);
+
+ //Save hosts
+ theApp->models ()->placesModel ()->save ();
+
}
void
SocialService::hostRecvMethodCallback (void *cls,
- const struct GNUNET_PSYC_MessageMethod
*meth,
- uint64_t message_id,
+ 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,
- "Test #: Host received method for message ID %i:\n"
- "%s\n",
- message_id, method_name);
- /* FIXME: check message */
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Test #: Host received method for message ID %i:\n" "%s\n",
+ message_id, method_name);
+ /* FIXME: check message */
}
@@ -127,21 +133,21 @@
const struct GNUNET_MessageHeader
*msg,
uint64_t message_id,
enum GNUNET_ENV_Operator oper,
- const char *name,
- const void *value,
+ const char *name, const void *value,
uint16_t value_size,
uint16_t full_value_size)
{
- /* GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Test #: Host received modifier for message ID %i:\n"
- "%i %s: %i %s\n",
- message_id, oper, name, value_size, value);
- */
+ /* GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ * "Test #: Host received modifier for message ID %i:\n"
+ * "%i %s: %i %s\n",
+ * message_id, oper, name, value_size, value);
+ */
- QString str = QString::fromLatin1((char *)value);
+ QString str = QString::fromLatin1 ((char *) value);
- qWarning() << "Host received modifier for message ID" << message_id <<
oper << name << value_size << str;
+ qWarning () << "Host received modifier for message ID" << message_id << oper
+ << name << value_size << str;
}
@@ -148,23 +154,22 @@
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)
+ uint64_t message_id, uint64_t data_offset,
+ const void *data, uint16_t data_size)
{
- /*GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Test #: Host received data for message ID %i:\n"
- "%.*s\n",
- message_id, data_size, data);*/
+ /*GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ * "Test #: Host received data for message ID %i:\n"
+ * "%.*s\n",
+ * message_id, data_size, data); */
- QString str = QString::fromLatin1((char *)data);
+ QString str = QString::fromLatin1 ((char *) data);
- Place* place = (Place*)cls;
+ 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);
+ place->addConversation (str);
}
@@ -171,44 +176,42 @@
void
SocialService::hostRecvEomCallback (void *cls,
const struct GNUNET_MessageHeader *msg,
- uint64_t message_id,
- uint8_t cancelled)
+ uint64_t message_id, uint8_t cancelled)
{
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Test #: Host received end of message ID %i, cancelled: %u\n",
- message_id, cancelled);
- /*
- switch (test)
- {
- case TEST_HOST_ANNOUNCE:
- test = TEST_HOST_ANNOUNCE_END;
- //host_announce2 ();
- break;
-
- case TEST_HOST_ANNOUNCE_END:
- guest_talk ();
- break;
-
- case TEST_GUEST_TALK:
- guest_leave ();
- break;
-
- default:
- GNUNET_assert (0);
- }*/
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Test #: Host received end of message ID %i, cancelled: %u\n",
+ message_id, cancelled);
+ /*
+ * switch (test)
+ * {
+ * case TEST_HOST_ANNOUNCE:
+ * test = TEST_HOST_ANNOUNCE_END;
+ * //host_announce2 ();
+ * break;
+ *
+ * case TEST_HOST_ANNOUNCE_END:
+ * guest_talk ();
+ * break;
+ *
+ * case TEST_GUEST_TALK:
+ * guest_leave ();
+ * break;
+ *
+ * default:
+ * GNUNET_assert (0);
+ * } */
}
void
-SocialService::hostAnswerDoorCallback (void *cls,
- struct GNUNET_SOCIAL_Nym *nym,
+SocialService::hostAnswerDoorCallback (void *cls, struct GNUNET_SOCIAL_Nym
*nym,
const char *method_name,
struct GNUNET_ENV_Environment *env,
- size_t data_size,
- const void *data)
+ size_t data_size, const void *data)
{
-
theApp->gnunet()->social()->hostAnswerDoor(cls,nym,method_name,env,data_size,data);
+ theApp->gnunet ()->social ()->hostAnswerDoor (cls, nym, method_name, env,
+ data_size, data);
@@ -215,60 +218,60 @@
}
void
-SocialService::hostAnswerDoor (void *cls,
- struct GNUNET_SOCIAL_Nym *nym,
+SocialService::hostAnswerDoor (void *cls, struct GNUNET_SOCIAL_Nym *nym,
const char *method_name,
struct GNUNET_ENV_Environment *env,
- size_t data_size,
- const void *data)
+ size_t data_size, const void *data)
{
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Host received entry request from guest .\n"
- );
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "%s\n%.*s\n",
- method_name, data_size, data);
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Host received entry request from guest .\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "%s\n%.*s\n", method_name, data_size,
+ data);
- Place* place = (Place*)cls;
+ Place *place = (Place *) cls;
- //TODO: Give option to deny
+ //TODO: Give option to deny
- GNUNET_PSYC_Message *join_resp = GNUNET_PSYC_message_create ("_admit_nym",
env,
- DATA2ARG
("Welcome, nym!"));
- GNUNET_SOCIAL_host_entry_decision (place->host(), nym, GNUNET_YES,
join_resp);
+ GNUNET_PSYC_Message *join_resp =
+ GNUNET_PSYC_message_create ("_admit_nym", env,
+ DATA2ARG ("Welcome, nym!"));
+ GNUNET_SOCIAL_host_entry_decision (place->host (), nym, GNUNET_YES,
+ join_resp);
- /*
- switch (test)
- {
- case TEST_HOST_ANSWER_DOOR_REFUSE:
- test = TEST_GUEST_RECV_ENTRY_DCSN_REFUSE;
- join_resp = GNUNET_PSYC_message_create ("_refuse_nym", env,
- DATA2ARG ("Go away!"));
- GNUNET_SOCIAL_host_entry_decision (hst, nym, GNUNET_NO, join_resp);
- break;
- case TEST_HOST_ANSWER_DOOR_ADMIT:
- test = TEST_GUEST_RECV_ENTRY_DCSN_ADMIT;
- join_resp = GNUNET_PSYC_message_create ("_admit_nym", env,
- DATA2ARG ("Welcome, nym!"));
- GNUNET_SOCIAL_host_entry_decision (hst, nym, GNUNET_YES, join_resp);
- break;
-
- default:
- GNUNET_assert (0);
- }*/
+ /*
+ * switch (test)
+ * {
+ * case TEST_HOST_ANSWER_DOOR_REFUSE:
+ * test = TEST_GUEST_RECV_ENTRY_DCSN_REFUSE;
+ * join_resp = GNUNET_PSYC_message_create ("_refuse_nym", env,
+ * DATA2ARG ("Go away!"));
+ * GNUNET_SOCIAL_host_entry_decision (hst, nym, GNUNET_NO, join_resp);
+ * break;
+ *
+ * case TEST_HOST_ANSWER_DOOR_ADMIT:
+ * test = TEST_GUEST_RECV_ENTRY_DCSN_ADMIT;
+ * join_resp = GNUNET_PSYC_message_create ("_admit_nym", env,
+ * DATA2ARG ("Welcome, nym!"));
+ * GNUNET_SOCIAL_host_entry_decision (hst, nym, GNUNET_YES, join_resp);
+ * break;
+ *
+ * default:
+ * GNUNET_assert (0);
+ * } */
}
-void SocialService::hostEnteredCallback (void *cls, int result,
- uint64_t max_message_id)
+void
+SocialService::hostEnteredCallback (void *cls, int result,
+ uint64_t max_message_id)
{
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Host entered to place.\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Host entered to place.\n");
- //GNUNET_IDENTITY_create (id, guest_name, &id_guest_created, NULL);
+ //GNUNET_IDENTITY_create (id, guest_name, &id_guest_created, NULL);
}
void
@@ -276,33 +279,36 @@
const struct GNUNET_SOCIAL_Nym *nym,
struct GNUNET_ENV_Environment *env)
{
- // FIXME: this function is not called yet
+ // FIXME: this function is not called yet
- const struct GNUNET_CRYPTO_EcdsaPublicKey *
- nym_key = GNUNET_SOCIAL_nym_get_key (nym);
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Nym %s has left the place.\n",
- GNUNET_CRYPTO_ecdsa_public_key_to_string (nym_key));
+ const struct GNUNET_CRYPTO_EcdsaPublicKey *nym_key =
+ GNUNET_SOCIAL_nym_get_key (nym);
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Nym %s has left the place.\n",
+ GNUNET_CRYPTO_ecdsa_public_key_to_string (nym_key));
- /*
- GNUNET_assert (0 == memcmp (&guest_pub_key, nym_key, sizeof (*nym_key)));
-
- GNUNET_SCHEDULER_add_now (&schedule_host_leave, NULL);*/
+ /*
+ * GNUNET_assert (0 == memcmp (&guest_pub_key, nym_key, sizeof (*nym_key)));
+ *
+ * GNUNET_SCHEDULER_add_now (&schedule_host_leave, NULL); */
}
void
-SocialService::guestRecvLocalEnterCallback (void *cls, int result, uint64_t
max_message_id)
+SocialService::guestRecvLocalEnterCallback (void *cls, int result,
+ uint64_t max_message_id)
{
- theApp->gnunet()->social()->guestRecvLocalEnter(cls,result,max_message_id);
+ theApp->gnunet ()->social ()->guestRecvLocalEnter (cls, result,
+ max_message_id);
}
void
-SocialService::guestRecvLocalEnter (void *cls, int result, uint64_t
max_message_id)
+SocialService::guestRecvLocalEnter (void *cls, int result,
+ uint64_t max_message_id)
{
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Guest entered to local place,
result : %i.\n",result);
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Guest entered to local place, result : %i.\n", result);
@@ -309,178 +315,188 @@
}
void
-SocialService::guestRecvEntryDecisionCallback (void *cls,
- int is_admitted,
- const struct
GNUNET_PSYC_Message *entry_msg)
+SocialService::guestRecvEntryDecisionCallback (void *cls, int is_admitted,
+ const struct GNUNET_PSYC_Message
+ *entry_msg)
{
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Guest received entry decision: %d.\n",
- is_admitted);
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Guest received entry decision:
%d.\n",
+ is_admitted);
- if (NULL != entry_msg)
- {
- struct GNUNET_ENV_Environment *env = GNUNET_ENV_environment_create ();
- const char *method_name = NULL;
- const void *data = NULL;
- uint16_t data_size = 0;
+ if (NULL != entry_msg)
+ {
+ struct GNUNET_ENV_Environment *env = GNUNET_ENV_environment_create ();
- struct GNUNET_PSYC_MessageHeader *
- pmsg = GNUNET_PSYC_message_header_create_from_psyc (entry_msg);
- GNUNET_PSYC_message_parse (pmsg, &method_name, env, &data, &data_size);
+ const char *method_name = NULL;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "%s\n%.*s\n",
- method_name, data_size, data);
- GNUNET_free (pmsg);
- /* FIXME: check response message */
- }
+ const void *data = NULL;
- /*
- switch (test)
- {
- case TEST_GUEST_RECV_ENTRY_DCSN_REFUSE:
- GNUNET_assert (GNUNET_NO == is_admitted);
- guest_enter ();
- break;
+ uint16_t data_size = 0;
- case TEST_GUEST_RECV_ENTRY_DCSN_ADMIT:
- GNUNET_assert (GNUNET_YES == is_admitted);
- host_announce ();
- break;
+ struct GNUNET_PSYC_MessageHeader *pmsg =
+ GNUNET_PSYC_message_header_create_from_psyc (entry_msg);
+ GNUNET_PSYC_message_parse (pmsg, &method_name, env, &data, &data_size);
- default:
- GNUNET_assert (0);
- }*/
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%s\n%.*s\n", method_name, data_size,
+ data);
+ GNUNET_free (pmsg);
+ /* FIXME: check response message */
+ }
+
+ /*
+ * switch (test)
+ * {
+ * case TEST_GUEST_RECV_ENTRY_DCSN_REFUSE:
+ * GNUNET_assert (GNUNET_NO == is_admitted);
+ * guest_enter ();
+ * break;
+ *
+ * case TEST_GUEST_RECV_ENTRY_DCSN_ADMIT:
+ * GNUNET_assert (GNUNET_YES == is_admitted);
+ * host_announce ();
+ * break;
+ *
+ * default:
+ * GNUNET_assert (0);
+ * } */
}
void
-SocialService::enterRoom(QString pubKey, QString peerIdentity)
+SocialService::enterRoom (QString pubKey, QString peerIdentity)
{
- emit enterRoomSignal(pubKey,peerIdentity);
+ emit enterRoomSignal (pubKey, peerIdentity);
}
void
-SocialService::enterRoomSlot(QString pubKey, QString peerIdentity)
+SocialService::enterRoomSlot (QString pubKey, QString peerIdentity)
{
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Entering to place %s as
guest.\n",pubKey.toStdString().c_str() );
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Entering to place %s as guest.\n",
+ pubKey.toStdString ().c_str ());
- GuestEnterMessage emsg;
+ 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);
+ 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_CRYPTO_EddsaPublicKey* convertedRoomKey = new
GNUNET_CRYPTO_EddsaPublicKey;
+ GNUNET_CRYPTO_EddsaPublicKey *convertedRoomKey =
+ new GNUNET_CRYPTO_EddsaPublicKey;
- int result = GNUNET_CRYPTO_eddsa_public_key_from_string
(pubKey.toStdString().c_str(),
- pubKey.length(),
- convertedRoomKey);
+ int result =
+ GNUNET_CRYPTO_eddsa_public_key_from_string (pubKey.toStdString ().
+ c_str (),
+ pubKey.length (),
+ convertedRoomKey);
- if(result != GNUNET_OK) // Failed conversion
- return;
+ if (result != GNUNET_OK) // Failed conversion
+ return;
- Place* newPlace = theApp->models()->placesModel()->add(pubKey);
+ Place *newPlace = theApp->models ()->placesModel ()->add (pubKey);
- newPlace->setName(pubKey);
- newPlace->setPublicKey(convertedRoomKey);
+ newPlace->setName (pubKey);
+ newPlace->setPublicKey (convertedRoomKey);
- GNUNET_SOCIAL_Slicer* slicer = GNUNET_SOCIAL_slicer_create ();
- GNUNET_SOCIAL_slicer_method_add (slicer, "",
- &hostRecvMethodCallback,
- &hostRecvModifierCallback,
- &hostRecvDataCallback,
- &hostRecvEomCallback,
- newPlace);
+ GNUNET_SOCIAL_Slicer *slicer = GNUNET_SOCIAL_slicer_create ();
- newPlace->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,
convertedRoomKey,
-
theApp->gnunet()->myPeer(), 0, NULL, emsg.msg,
- slicer,
&guestRecvLocalEnterCallback,
-
&guestRecvEntryDecisionCallback, newPlace);
- newPlace->setSocialGuest(gst);
- connect(newPlace,&Place::guestTalkSignal,
- this,&SocialService::guestTalk, Qt::QueuedConnection);
+ //TODO change place pub key to arbitrary value
+ GNUNET_SOCIAL_Guest *gst =
+ GNUNET_SOCIAL_guest_enter (m_config, m_hostEgo, convertedRoomKey,
+ theApp->gnunet ()->myPeer (), 0, NULL,
+ emsg.msg,
+ slicer, &guestRecvLocalEnterCallback,
+ &guestRecvEntryDecisionCallback, newPlace);
+ newPlace->setSocialGuest (gst);
+ connect (newPlace, &Place::guestTalkSignal, this, &SocialService::guestTalk,
+ Qt::QueuedConnection);
+
+
}
static void
transmit_resume (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transmission resumed.\n");
- TransmitClosure *tmit = (TransmitClosure *)cls;
- if (NULL != tmit->host_ann)
- GNUNET_SOCIAL_host_announce_resume (tmit->host_ann);
- else
- GNUNET_SOCIAL_guest_talk_resume (tmit->guest_talk);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transmission resumed.\n");
+ TransmitClosure *tmit = (TransmitClosure *) cls;
+
+ if (NULL != tmit->host_ann)
+ GNUNET_SOCIAL_host_announce_resume (tmit->host_ann);
+ else
+ GNUNET_SOCIAL_guest_talk_resume (tmit->guest_talk);
}
int
-notify_data (void *cls, uint16_t *data_size, void *data)
+notify_data (void *cls, uint16_t * data_size, void *data)
{
- TransmitClosure *tmit = (TransmitClosure *)cls;
- if (NULL != tmit->env)
- {
- GNUNET_ENV_environment_destroy (tmit->env);
- tmit->env = NULL;
- }
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "data_sent: %z, data_size: %u\n",
- tmit->data_sent, *data_size);
- std::string sub = tmit->data.substr (tmit->data_sent, *data_size);
- *data_size = sub.size ();
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "data_size: %u\n", *data_size);
- memcpy (data, sub.c_str (), *data_size);
- tmit->data_sent += *data_size;
+ TransmitClosure *tmit = (TransmitClosure *) cls;
- return (tmit->data.size () <= tmit->data_sent)
- ? GNUNET_YES : GNUNET_NO;
+ if (NULL != tmit->env)
+ {
+ GNUNET_ENV_environment_destroy (tmit->env);
+ tmit->env = NULL;
+ }
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "data_sent: %z, data_size: %u\n",
+ tmit->data_sent, *data_size);
+ std::string sub = tmit->data.substr (tmit->data_sent, *data_size);
+ *data_size = sub.size ();
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "data_size: %u\n", *data_size);
+ memcpy (data, sub.c_str (), *data_size);
+ tmit->data_sent += *data_size;
+
+ return (tmit->data.size () <= tmit->data_sent) ? GNUNET_YES : GNUNET_NO;
}
void
-SocialService::guestTalk (Place* place, QString text)
+SocialService::guestTalk (Place * place, QString text)
{
- TransmitClosure* tmit = new TransmitClosure;
- tmit->env = NULL;
- tmit->data = text.toStdString();
- tmit->data_sent = 0;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "data: %s\n", tmit->data.c_str ());
- tmit->guest_talk
- = GNUNET_SOCIAL_guest_talk (place->socialGuest(),
"_message_guest", NULL,
- ¬ify_data, tmit,
- GNUNET_SOCIAL_TALK_NONE);
- place->addConversation(text);
+ TransmitClosure *tmit = new TransmitClosure;
+
+ tmit->env = NULL;
+ tmit->data = text.toStdString ();
+ tmit->data_sent = 0;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "data: %s\n", tmit->data.c_str ());
+ tmit->guest_talk =
+ GNUNET_SOCIAL_guest_talk (place->socialGuest (), "_message_guest", NULL,
+ ¬ify_data, tmit, GNUNET_SOCIAL_TALK_NONE);
+ place->addConversation (text);
}
void
-SocialService::hostTalk(Place* place, QString text)
+SocialService::hostTalk (Place * place, QString text)
{
- TransmitClosure* tmit = new TransmitClosure();
+ TransmitClosure *tmit = new TransmitClosure ();
+
tmit->env = NULL;
- tmit->data = text.toStdString();
+ tmit->data = text.toStdString ();
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,
+ tmit->host_ann =
+ 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 2015-11-12 18:30:37 UTC
(rev 36655)
+++ gnunet-qt/secushare/core/social/socialservice.h 2015-11-12 18:30:41 UTC
(rev 36656)
@@ -20,98 +20,78 @@
struct GNUNET_SOCIAL_Announcement *host_ann;
struct GNUNET_SOCIAL_TalkRequest *guest_talk;
struct GNUNET_ENV_Environment *env;
- std::string data;
+ std::string data;
size_t data_sent;
} TransmitClosure;
class Place;
-class SocialService : public QObject
+
+class SocialService:public QObject
{
- Q_OBJECT
-public:
- explicit SocialService(QObject *parent = 0);
+Q_OBJECT public:
+ explicit SocialService (QObject * parent = 0);
- 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 char *method_name);
+ 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 char *method_name);
- static void
- hostRecvModifierCallback (void *cls,
- const struct GNUNET_MessageHeader *msg,
- uint64_t message_id,
- enum GNUNET_ENV_Operator oper,
- const char *name,
- const void *value,
- uint16_t value_size,
- uint16_t full_value_size);
+ static void hostRecvModifierCallback (void *cls,
+ const struct GNUNET_MessageHeader *msg,
+ uint64_t message_id,
+ enum GNUNET_ENV_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);
- static void
- hostRecvEomCallback (void *cls,
- const struct GNUNET_MessageHeader *msg,
- uint64_t message_id,
- uint8_t cancelled);
- static void
- hostAnswerDoorCallback (void *cls,
- struct GNUNET_SOCIAL_Nym *nym,
- const char *method_name,
- struct GNUNET_ENV_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,
- const void *data);
- static void hostEnteredCallback (void *cls, int result,
- uint64_t max_message_id);
- static void
- hostFarewellCallback (void *cls,
- const struct GNUNET_SOCIAL_Nym *nym,
- struct GNUNET_ENV_Environment *env);
+ 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);
+ static void hostRecvEomCallback (void *cls,
+ const struct GNUNET_MessageHeader *msg,
+ uint64_t message_id, uint8_t cancelled);
+ static void hostAnswerDoorCallback (void *cls, struct GNUNET_SOCIAL_Nym *nym,
+ const char *method_name,
+ struct GNUNET_ENV_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,
+ const void *data);
+ static void hostEnteredCallback (void *cls, int result,
+ uint64_t max_message_id);
+ static void hostFarewellCallback (void *cls,
+ const struct GNUNET_SOCIAL_Nym *nym,
+ struct GNUNET_ENV_Environment *env);
- static void
- guestRecvEntryDecisionCallback (void *cls,
- int is_admitted,
- const struct GNUNET_PSYC_Message *entry_resp);
+ static void guestRecvEntryDecisionCallback (void *cls, int is_admitted,
+ const struct GNUNET_PSYC_Message
+ *entry_resp);
- static void
- guestRecvLocalEnterCallback (void *cls, int result, uint64_t
max_message_id);
- void
- guestRecvLocalEnter(void *cls, int result, uint64_t max_message_id);
+ static void guestRecvLocalEnterCallback (void *cls, int result,
+ uint64_t max_message_id);
+ void guestRecvLocalEnter (void *cls, int result, uint64_t max_message_id);
- void start(GNUNET_CONFIGURATION_Handle *config);
- Q_INVOKABLE void createPlace(QString name);
- void createPlaceSlot(QString name);
- Q_INVOKABLE void enterRoom(QString pubKey, QString peerIdentity);
+ void start (GNUNET_CONFIGURATION_Handle * config);
+ Q_INVOKABLE void createPlace (QString name);
+ void createPlaceSlot (QString name);
+ Q_INVOKABLE void enterRoom (QString pubKey, QString peerIdentity);
-signals:
- void createPlaceSignal(QString name);
- void enterRoomSignal(QString pubKey, QString peerIdentity);
-public slots:
-
- void enterRoomSlot(QString pubKey, QString peerIdentity);
- void guestTalk(Place *place, QString text);
- void hostTalk(Place *place, QString text);
+ signals:void createPlaceSignal (QString name);
+ void enterRoomSignal (QString pubKey, QString peerIdentity);
+ public slots:void enterRoomSlot (QString pubKey, QString peerIdentity);
+ void guestTalk (Place * place, QString text);
+ void hostTalk (Place * place, QString text);
private:
- GNUNET_IDENTITY_Ego* m_hostEgo;
+ GNUNET_IDENTITY_Ego * m_hostEgo;
- GNUNET_CONFIGURATION_Handle *m_config;
+ GNUNET_CONFIGURATION_Handle *m_config;
};
Modified: gnunet-qt/secushare/main.cpp
===================================================================
--- gnunet-qt/secushare/main.cpp 2015-11-12 18:30:37 UTC (rev 36655)
+++ gnunet-qt/secushare/main.cpp 2015-11-12 18:30:41 UTC (rev 36656)
@@ -6,35 +6,39 @@
#include "psyc.h"
#include "core/psyccore.h"
-int main(int argc, char *argv[])
+int
+main (int argc, char *argv[])
{
- QApplication app(argc, argv);
- qWarning("Starting PSYC");
+ QApplication app (argc, argv);
- //Start our core object
- Psyc psyc;
+ qWarning ("Starting PSYC");
- QQmlApplicationEngine engine(QUrl(QStringLiteral("qrc:///qml/main.qml")));
+ //Start our core object
+ Psyc psyc;
- //Connect Window to quit signal
- QObject *topLevel = engine.rootObjects().value(0);
- theWindow = qobject_cast<QQuickWindow *>(topLevel);
- if ( !theWindow ) {
- qWarning("Error: Your root item has to be a Window.");
- return -1;
- }
+ QQmlApplicationEngine engine (QUrl (QStringLiteral ("qrc:///qml/main.qml")));
- QObject::connect(&engine, SIGNAL(quit()), &app, SLOT(quit()));
+ //Connect Window to quit signal
+ QObject *topLevel = engine.rootObjects ().value (0);
- psyc.registerImageProvider(&engine);
+ theWindow = qobject_cast < QQuickWindow * >(topLevel);
+ if (!theWindow)
+ {
+ qWarning ("Error: Your root item has to be a Window.");
+ return -1;
+ }
- //Create the tray icon
- theApp->setupTray();
+ QObject::connect (&engine, SIGNAL (quit ()), &app, SLOT (quit ()));
- theWindow->setTitle(QString("secushare 0.1"));
- theWindow->setIcon(QIcon(":/assets/icon.ico"));
+ psyc.registerImageProvider (&engine);
- theWindow->show();
+ //Create the tray icon
+ theApp->setupTray ();
- return app.exec();
+ theWindow->setTitle (QString ("secushare 0.1"));
+ theWindow->setIcon (QIcon (":/assets/icon.ico"));
+
+ theWindow->show ();
+
+ return app.exec ();
}
Modified: gnunet-qt/secushare/models/IdentityModel.cpp
===================================================================
--- gnunet-qt/secushare/models/IdentityModel.cpp 2015-11-12 18:30:37 UTC
(rev 36655)
+++ gnunet-qt/secushare/models/IdentityModel.cpp 2015-11-12 18:30:41 UTC
(rev 36656)
@@ -27,65 +27,73 @@
#include <QQmlEngine>
-IdentityModel::IdentityModel(QObject *parent) :
- QAbstractListModel(parent)
+IdentityModel::IdentityModel (QObject * parent):
+QAbstractListModel (parent)
{
- //connect(this, &IdentityModel::addNewPeerSignal, this,
&IdentityModel::addNewPeerSlot, Qt::BlockingQueuedConnection);
- connect(this, &IdentityModel::addNewIdentitySignal, this,
&IdentityModel::addNewIdentitySlot, Qt::BlockingQueuedConnection);
+ //connect(this, &IdentityModel::addNewPeerSignal, this,
&IdentityModel::addNewPeerSlot, Qt::BlockingQueuedConnection);
+ connect (this, &IdentityModel::addNewIdentitySignal, this,
+ &IdentityModel::addNewIdentitySlot, Qt::BlockingQueuedConnection);
}
-int IdentityModel::rowCount(const QModelIndex& parent) const
+int
+IdentityModel::rowCount (const QModelIndex & parent) const const
{
- Q_UNUSED(parent);
- return m_data.size()+1; // PLus one is because the last one is a "<CREATE>"
+ Q_UNUSED (parent);
+ return m_data.size () + 1; // PLus one is because the last one is a
"<CREATE>"
}
-bool IdentityModel::contains(QString id)
+bool
+IdentityModel::contains (QString id)
{
- return m_lookupIndex.contains(id);
+ return m_lookupIndex.contains (id);
}
-QVariant IdentityModel::data(const QModelIndex& index, int role) const
+QVariant
+IdentityModel::data (const QModelIndex & index, int role) const const
{
- if (index.row() < 0 || index.row() > m_data.count())
- return QVariant();
- else if ( index.row() == m_data.count())
- return QString("<Create>");
+ if (index.row () < 0 || index.row () > m_data.count ())
+ return QVariant ();
+ else if (index.row () == m_data.count ())
+ return QString ("<Create>");
- Identity* iden = m_data[index.row()];
+ Identity *iden = m_data[index.row ()];
- switch(role)
- {
- case NAME:
- return iden->name();
- break;
- default:
- return QVariant::Invalid;
- }
+ switch (role)
+ {
+ case NAME:
+ return iden->name ();
+ break;
+ default:
+ return QVariant::Invalid;
+ }
- return QVariant::Invalid;
+ return QVariant::Invalid;
}
-QHash<int, QByteArray> IdentityModel::roleNames() const {
- QHash<int, QByteArray> roles;
- roles[NAME] = "name";
+QHash < int, QByteArray >
+IdentityModel::roleNames () const const
+{
+ QHash < int, QByteArray > roles;
+ roles[NAME] = "name";
- return roles;
+
+ return roles;
}
-void IdentityModel::modifiedSlot(int indexRow)
+void
+IdentityModel::modifiedSlot (int indexRow)
{
- QModelIndex modelIndex = this->index(indexRow);
+ QModelIndex modelIndex = this->index (indexRow);
- emit dataChanged(modelIndex, modelIndex);
+ emit dataChanged (modelIndex, modelIndex);
}
/**
@@ -93,15 +101,18 @@
* @param key
* @return Return the new created place
*/
-Identity* IdentityModel::add(QString key, QString name, struct
GNUNET_IDENTITY_Ego *ego)
+Identity *
+IdentityModel::add (QString key, QString name, struct GNUNET_IDENTITY_Ego *ego)
{
- Identity* iden = new Identity(key);
- iden->setName(name);
- iden->setEgo(ego);
+ Identity *iden = new Identity (key);
- iden->moveToThread(this->thread());
- emit addNewIdentitySignal(iden,key);
- return iden;
+ iden->setName (name);
+ iden->setEgo (ego);
+
+ iden->moveToThread (this->thread ());
+ emit addNewIdentitySignal (iden, key);
+
+ return iden;
}
@@ -110,72 +121,76 @@
* @param key, the place ID.
* @return return the same place as item
*/
-Identity* IdentityModel::addNewIdentitySlot(Identity* item, QString key)
+Identity *
+IdentityModel::addNewIdentitySlot (Identity * item, QString key)
{
- //Search if already exists
- if (m_lookupIndex.contains(key))
- {
- return NULL;
- }
- else
- {
- int index = m_data.count();
- beginInsertRows(QModelIndex(), index, index);
- m_data.append(item);
- item->setIndex(index);
+ //Search if already exists
+ if (m_lookupIndex.contains (key))
+ {
+ return NULL;
+ }
+ else
+ {
+ int index = m_data.count ();
- //Notify modifications
- connect(item, &Identity::modifiedSignal,this,
&IdentityModel::modifiedSlot);
+ beginInsertRows (QModelIndex (), index, index);
+ m_data.append (item);
+ item->setIndex (index);
- m_lookupIndex[key] = index;
- endInsertRows();
- return item;
- }
+ //Notify modifications
+ connect (item, &Identity::modifiedSignal, this,
+ &IdentityModel::modifiedSlot);
+ m_lookupIndex[key] = index;
+ endInsertRows ();
+ return item;
+ }
+
}
-Identity* IdentityModel::get(QString key)
+Identity *
+IdentityModel::get (QString key)
{
- if (m_lookupIndex.contains(key))
- {
- Identity* iden = m_data[m_lookupIndex[key]];
- return iden;
+ if (m_lookupIndex.contains (key))
+ {
+ Identity *iden = m_data[m_lookupIndex[key]];
- }
- else
- return NULL;
+ return iden;
+
+ }
+ else
+ return NULL;
}
-Identity* IdentityModel::get(QModelIndex index)
+Identity *
+IdentityModel::get (QModelIndex index)
{
- if(getCount() <= index.row())
- return NULL;
+ if (getCount () <= index.row ())
+ return NULL;
- return m_data[index.row()];
+ return m_data[index.row ()];
}
-Identity* IdentityModel::get(int index)
+Identity *
+IdentityModel::get (int index)
{
- if(getCount() <= index)
- return NULL;
+ if (getCount () <= index)
+ return NULL;
- Identity *iden = m_data[index];
+ Identity *iden = m_data[index];
- //Set he ownership so QML don't delete it.
- QQmlEngine::setObjectOwnership(iden, QQmlEngine::CppOwnership);
+ //Set he ownership so QML don't delete it.
+ QQmlEngine::setObjectOwnership (iden, QQmlEngine::CppOwnership);
- return iden;
+ return iden;
}
-int IdentityModel::getCount()
+int
+IdentityModel::getCount ()
{
- return m_data.count();
+ return m_data.count ();
}
-
-
-
-
Modified: gnunet-qt/secushare/models/IdentityModel.h
===================================================================
--- gnunet-qt/secushare/models/IdentityModel.h 2015-11-12 18:30:37 UTC (rev
36655)
+++ gnunet-qt/secushare/models/IdentityModel.h 2015-11-12 18:30:41 UTC (rev
36656)
@@ -26,47 +26,43 @@
class Identity;
-class IdentityModel : public QAbstractListModel
+
+class IdentityModel:public QAbstractListModel
{
- Q_OBJECT
+Q_OBJECT public:
+ enum IdentityRoles
+ { NAME = Qt::UserRole + 1, NB_PLACE_COLUMNS };
public:
- enum IdentityRoles { NAME = Qt::UserRole + 1, NB_PLACE_COLUMNS };
+ explicit IdentityModel (QObject * parent = 0);
-public:
- explicit IdentityModel(QObject *parent = 0);
+ Identity *add (QString key, QString name, struct GNUNET_IDENTITY_Ego *ego);
+ Q_INVOKABLE int getCount ();
+ bool contains (QString id);
+ Q_INVOKABLE Identity *get (int index);
+ Identity *get (QModelIndex index);
+ Identity *get (QString key);
- Identity *add(QString key, QString name, struct GNUNET_IDENTITY_Ego *ego);
- Q_INVOKABLE int getCount();
- bool contains(QString id);
+ signals:void addNewIdentitySignal (Identity * item, QString key);
- Q_INVOKABLE Identity *get(int index);
- Identity *get(QModelIndex index);
- Identity *get(QString key);
+ public slots:void modifiedSlot (int indexRow);
+ private slots:Identity * addNewIdentitySlot (Identity * item, QString name);
-signals:
- void addNewIdentitySignal(Identity* item, QString key);
-
-public slots:
- void modifiedSlot(int indexRow);
-private slots:
- Identity *addNewIdentitySlot(Identity* item, QString name);
-
private:
- int rowCount(const QModelIndex& parent) const;
- QVariant data(const QModelIndex& index, int role) const;
- QHash<int, QByteArray> roleNames() const;
+ int rowCount (const QModelIndex & parent) const;
+ QVariant data (const QModelIndex & index, int role) const;
+ QHash < int, QByteArray > roleNames () const;
private:
- QHash<QString, int> m_lookupIndex;
- QList<Identity*> m_data;
+ QHash < QString, int >m_lookupIndex;
+ QList < Identity * >m_data;
-
+
};
#endif // PLACESMODEL_H
Modified: gnunet-qt/secushare/models/PlacesModel.cpp
===================================================================
--- gnunet-qt/secushare/models/PlacesModel.cpp 2015-11-12 18:30:37 UTC (rev
36655)
+++ gnunet-qt/secushare/models/PlacesModel.cpp 2015-11-12 18:30:41 UTC (rev
36656)
@@ -34,15 +34,16 @@
#include <QQmlEngine>
-PlacesModel::PlacesModel(QObject *parent) :
- QAbstractListModel(parent)
+PlacesModel::PlacesModel (QObject * parent):
+QAbstractListModel (parent)
{
- //connect(this, &PlacesModel::addNewPeerSignal, this,
&PlacesModel::addNewPeerSlot, Qt::BlockingQueuedConnection);
- connect(this, &PlacesModel::addNewPeerSignal, this,
&PlacesModel::addNewPeerSlot);
+ //connect(this, &PlacesModel::addNewPeerSignal, this,
&PlacesModel::addNewPeerSlot, Qt::BlockingQueuedConnection);
+ connect (this, &PlacesModel::addNewPeerSignal, this,
+ &PlacesModel::addNewPeerSlot);
}
-PlacesModel::~PlacesModel()
+PlacesModel::~PlacesModel ()
{
}
@@ -51,112 +52,129 @@
/**
* @brief PlacesModel::save, will save the list of places
*/
-void PlacesModel::save(){
- QString filename = thePrefs->getFolder() + "/rooms.keys";
- QFile file(filename);
+void
+PlacesModel::save ()
+{
+ QString filename = thePrefs->getFolder () + "/rooms.keys";
- if(!file.open(QIODevice::WriteOnly))
- {
- qDebug() << "Could not open " << filename;
- return;
- }
+ QFile file (filename);
- QDataStream out(&file);
- //out.setVersion(QDataStream::Qt_5_1);
+ if (!file.open (QIODevice::WriteOnly))
+ {
+ qDebug () << "Could not open " << filename;
+ return;
+ }
+ QDataStream out (&file);
- foreach (Place* place, m_data) {
- out << place->name();
- out << place->isHost();
+ //out.setVersion(QDataStream::Qt_5_1);
- }
+
+ foreach (Place * place, m_data)
+ {
+ out << place->name ();
+ out << place->isHost ();
+
+ }
}
-void PlacesModel::load()
+void
+PlacesModel::load ()
{
- QString filename = thePrefs->getFolder() + "/rooms.keys";
- QFile file(filename);
+ QString filename = thePrefs->getFolder () + "/rooms.keys";
- if(!file.open(QIODevice::ReadOnly))
- {
- qDebug() << "Could not open " << filename;
- return;
- }
+ QFile file (filename);
- QDataStream in(&file);
- //out.setVersion(QDataStream::Qt_5_1);
+ if (!file.open (QIODevice::ReadOnly))
+ {
+ qDebug () << "Could not open " << filename;
+ return;
+ }
+ QDataStream in (&file);
- while (!in.atEnd()) {
- QString publicKey;
- bool isHost;
+ //out.setVersion(QDataStream::Qt_5_1);
- in >> publicKey >> isHost;
+ while (!in.atEnd ())
+ {
+ QString publicKey;
- qWarning() << publicKey << " Is host:" << isHost ;
+ bool isHost;
- theApp->gnunet()->social()->enterRoom(publicKey,"");
- }
+ in >> publicKey >> isHost;
+
+ qWarning () << publicKey << " Is host:" << isHost;
+
+ theApp->gnunet ()->social ()->enterRoom (publicKey, "");
+ }
+
}
-int PlacesModel::rowCount(const QModelIndex& parent) const
+int
+PlacesModel::rowCount (const QModelIndex & parent) const const
{
- Q_UNUSED(parent);
- return m_data.size();
+ Q_UNUSED (parent);
+ return m_data.size ();
}
-bool PlacesModel::contains(QString id)
+bool
+PlacesModel::contains (QString id)
{
- return m_lookupIndex.contains(id);
+ return m_lookupIndex.contains (id);
}
-QVariant PlacesModel::data(const QModelIndex& index, int role) const
+QVariant
+PlacesModel::data (const QModelIndex & index, int role) const const
{
- if (index.row() < 0 || index.row() >= m_data.count())
- return QVariant();
+ if (index.row () < 0 || index.row () >= m_data.count ())
+ return QVariant ();
- Place* peer = m_data[index.row()];
+ Place *peer = m_data[index.row ()];
- switch(role)
- {
- case NAME:
- return peer->name();
- break;
- case TYPE:
- return peer->type();
- break;
- case STATUS:
- return peer->status();
- break;
- default:
- return QVariant::Invalid;
- }
+ switch (role)
+ {
+ case NAME:
+ return peer->name ();
+ break;
+ case TYPE:
+ return peer->type ();
+ break;
+ case STATUS:
+ return peer->status ();
+ break;
+ default:
+ return QVariant::Invalid;
+ }
- return QVariant::Invalid;
+ return QVariant::Invalid;
}
-QHash<int, QByteArray> PlacesModel::roleNames() const {
- QHash<int, QByteArray> roles;
- roles[NAME] = "name";
- roles[TYPE] = "type";
- roles[STATUS] = "status";
+QHash < int, QByteArray >
+PlacesModel::roleNames () const const
+{
+ QHash < int, QByteArray > roles;
- return roles;
+ roles[NAME] = "name";
+ roles[TYPE] = "type";
+ roles[STATUS] = "status";
+
+ return roles;
}
-void PlacesModel::modifiedSlot(int indexRow)
+void
+PlacesModel::modifiedSlot (int indexRow)
{
- QModelIndex modelIndex = this->index(indexRow);
+ QModelIndex modelIndex = this->index (indexRow);
- emit dataChanged(modelIndex, modelIndex);
+ emit dataChanged (modelIndex, modelIndex);
}
@@ -165,12 +183,15 @@
* @param key
* @return Return the new created place
*/
-Place* PlacesModel::add(QString key)
+Place *
+PlacesModel::add (QString key)
{
- Place* peer = new Place(key);
- peer->moveToThread(this->thread());
- emit addNewPeerSignal(peer,key);
- return peer;
+ Place *peer = new Place (key);
+
+ peer->moveToThread (this->thread ());
+ emit addNewPeerSignal (peer, key);
+
+ return peer;
}
@@ -179,71 +200,78 @@
* @param key, the place ID.
* @return return the same place as item
*/
-Place* PlacesModel::addNewPeerSlot(Place* item, QString key)
+Place *
+PlacesModel::addNewPeerSlot (Place * item, QString key)
{
- //Search if already exists
- if (m_lookupIndex.contains(key))
- {
- return NULL;
- }
- else
- {
- int index = m_data.count();
- beginInsertRows(QModelIndex(), index, index);
- m_data.append(item);
- item->setIndex(index);
+ //Search if already exists
+ if (m_lookupIndex.contains (key))
+ {
+ return NULL;
+ }
+ else
+ {
+ int index = m_data.count ();
- //Notify modifications
- connect(item, &Place::modifiedSignal,this, &PlacesModel::modifiedSlot);
+ beginInsertRows (QModelIndex (), index, index);
+ m_data.append (item);
+ item->setIndex (index);
- m_lookupIndex[key] = index;
- endInsertRows();
- save();
- return item;
- }
+ //Notify modifications
+ connect (item, &Place::modifiedSignal, this, &PlacesModel::modifiedSlot);
+ m_lookupIndex[key] = index;
+ endInsertRows ();
+ save ();
+ return item;
+ }
+
}
-Place* PlacesModel::get(QString key)
+Place *
+PlacesModel::get (QString key)
{
- if (m_lookupIndex.contains(key))
- {
- Place* peer = m_data[m_lookupIndex[key]];
- return peer;
+ if (m_lookupIndex.contains (key))
+ {
+ Place *peer = m_data[m_lookupIndex[key]];
- }
- else
- return NULL;
+ return peer;
+
+ }
+ else
+ return NULL;
}
-Place* PlacesModel::get(QModelIndex index)
+Place *
+PlacesModel::get (QModelIndex index)
{
- if(getCount() < index.row())
- return NULL;
+ if (getCount () < index.row ())
+ return NULL;
- return m_data[index.row()];
+ return m_data[index.row ()];
}
-Place* PlacesModel::get(int index)
+Place *
+PlacesModel::get (int index)
{
- if(getCount() < index)
- return NULL;
+ if (getCount () < index)
+ return NULL;
- Place *peer = m_data[index];
+ Place *peer = m_data[index];
- //Set he ownership so QML don't delete it.
- QQmlEngine::setObjectOwnership(peer, QQmlEngine::CppOwnership);
+ //Set he ownership so QML don't delete it.
+ QQmlEngine::setObjectOwnership (peer, QQmlEngine::CppOwnership);
- return peer;
+ return peer;
}
-int PlacesModel::getCount()
+int
+PlacesModel::getCount ()
{
- return m_data.count();
+ return m_data.count ();
}
Modified: gnunet-qt/secushare/models/PlacesModel.h
===================================================================
--- gnunet-qt/secushare/models/PlacesModel.h 2015-11-12 18:30:37 UTC (rev
36655)
+++ gnunet-qt/secushare/models/PlacesModel.h 2015-11-12 18:30:41 UTC (rev
36656)
@@ -26,50 +26,46 @@
class Place;
-class PlacesModel : public QAbstractListModel
+
+class PlacesModel:public QAbstractListModel
{
- Q_OBJECT
+Q_OBJECT public:
+ enum PlaceRoles
+ { NAME = Qt::UserRole + 1, TYPE, STATUS, NB_PLACE_COLUMNS };
public:
- enum PlaceRoles { NAME = Qt::UserRole + 1, TYPE, STATUS, NB_PLACE_COLUMNS
};
+ explicit PlacesModel (QObject * parent = 0);
+ struct Bandwidth_Info_Struct *getTotalBandwidth ();
+ Place *add (QString key);
+ int getCount ();
+ bool contains (QString id);
-public:
- explicit PlacesModel(QObject *parent = 0);
- struct Bandwidth_Info_Struct *getTotalBandwidth();
+ Q_INVOKABLE Place *get (int index);
+ Place *get (QModelIndex index);
+ Place *get (QString key);
- Place *add(QString key);
- int getCount();
- bool contains(QString id);
+ void save ();
+ void load ();
+ ~PlacesModel ();
+ signals:void addNewPeerSignal (Place * item, QString key);
- Q_INVOKABLE Place *get(int index);
- Place *get(QModelIndex index);
- Place *get(QString key);
+ public slots:void modifiedSlot (int indexRow);
+ private slots:Place * addNewPeerSlot (Place * item, QString name);
- void save();
- void load();
- ~PlacesModel();
-signals:
- void addNewPeerSignal(Place* item, QString key);
-
-public slots:
- void modifiedSlot(int indexRow);
-private slots:
- Place *addNewPeerSlot(Place* item, QString name);
-
private:
- int rowCount(const QModelIndex& parent) const;
- QVariant data(const QModelIndex& index, int role) const;
- QHash<int, QByteArray> roleNames() const;
+ int rowCount (const QModelIndex & parent) const;
+ QVariant data (const QModelIndex & index, int role) const;
+ QHash < int, QByteArray > roleNames () const;
private:
- QHash<QString, int> m_lookupIndex;
- QList<Place*> m_data;
+ QHash < QString, int >m_lookupIndex;
+ QList < Place * >m_data;
-
+
};
#endif // PLACESMODEL_H
Modified: gnunet-qt/secushare/models/models.cpp
===================================================================
--- gnunet-qt/secushare/models/models.cpp 2015-11-12 18:30:37 UTC (rev
36655)
+++ gnunet-qt/secushare/models/models.cpp 2015-11-12 18:30:41 UTC (rev
36656)
@@ -23,24 +23,26 @@
#include "core/social/place.h"
#include "models/IdentityModel.h"
-Models::Models(QObject *parent) :
- QObject(parent)
+Models::Models (QObject * parent):
+QObject (parent)
{
- m_places = new PlacesModel(this);
- m_identities = new IdentityModel(this);
+ m_places = new PlacesModel (this);
+ m_identities = new IdentityModel (this);
- test();
+ test ();
}
-Models::~Models()
+Models::~Models ()
{
- delete m_places;
- m_places = NULL;
+ delete m_places;
+
+ m_places = NULL;
}
-void Models::test()
+void
+Models::test ()
{
/*
Place* place = m_places->add("test");
Modified: gnunet-qt/secushare/models/models.h
===================================================================
--- gnunet-qt/secushare/models/models.h 2015-11-12 18:30:37 UTC (rev 36655)
+++ gnunet-qt/secushare/models/models.h 2015-11-12 18:30:41 UTC (rev 36656)
@@ -25,36 +25,34 @@
class PlacesModel;
+
class IdentityModel;
-class Models : public QObject
+
+class Models:public QObject
{
- Q_OBJECT
- Q_PROPERTY(PlacesModel * placesModel READ placesModel NOTIFY
placesModelChanged)
- Q_PROPERTY(IdentityModel * identityModel READ identityModel NOTIFY
identityModelChanged)
+Q_OBJECT Q_PROPERTY (PlacesModel * placesModel READ placesModel NOTIFY
placesModelChanged) Q_PROPERTY (IdentityModel * identityModel READ
identityModel NOTIFY identityModelChanged) public:
+ explicit Models (QObject * parent =
+ 0);
+ ~Models ();
-public:
- explicit Models(QObject *parent = 0);
- ~Models();
+ PlacesModel *placesModel () const
+ {
+ return m_places;
+ }
- PlacesModel* placesModel() const
- { return m_places; }
+ IdentityModel *identityModel () const
+ {
+ return m_identities;
+ }
- IdentityModel* identityModel() const
- { return m_identities; }
+ void test ();
+ signals:void placesModelChanged (PlacesModel *);
+ void identityModelChanged (IdentityModel *);
+public slots:private:
- void test();
-signals:
- void placesModelChanged(PlacesModel*);
- void identityModelChanged(IdentityModel*);
-public slots:
+ PlacesModel * m_places;
+ IdentityModel *m_identities;
-private:
-
- PlacesModel* m_places;
- IdentityModel* m_identities;
-
};
#endif // MODELS_H
-
-
Modified: gnunet-qt/secushare/preferences/preferences.cpp
===================================================================
--- gnunet-qt/secushare/preferences/preferences.cpp 2015-11-12 18:30:37 UTC
(rev 36655)
+++ gnunet-qt/secushare/preferences/preferences.cpp 2015-11-12 18:30:41 UTC
(rev 36656)
@@ -28,27 +28,30 @@
#include "psyc.h"
#include "core/identity/identity.h"
-Preferences::Preferences(QObject *parent)
- : QSettings(QSettings::IniFormat, QSettings::UserScope,
- "gnunet", "secushare", parent)
+Preferences::Preferences (QObject * parent):QSettings (QSettings::IniFormat,
QSettings::UserScope, "gnunet", "secushare",
+ parent)
{
- sync();
+ sync ();
}
-void Preferences::save()
+void
+Preferences::save ()
{
- sync();
+ sync ();
}
-QString Preferences::getFolder()
+QString
+Preferences::getFolder ()
{
- QString filepath = fileName();
- QFileInfo fi(filepath);
+ QString filepath = fileName ();
- QDir fileDir = fi.dir();
- QString fileDirStr = fileDir.absolutePath();
+ QFileInfo fi (filepath);
- Identity* iden = theApp->identity();
+ QDir fileDir = fi.dir ();
- return fileDirStr + "/" + applicationName() + "/" + iden->name();
+ QString fileDirStr = fileDir.absolutePath ();
+
+ Identity *iden = theApp->identity ();
+
+ return fileDirStr + "/" + applicationName () + "/" + iden->name ();
}
Modified: gnunet-qt/secushare/preferences/preferences.h
===================================================================
--- gnunet-qt/secushare/preferences/preferences.h 2015-11-12 18:30:37 UTC
(rev 36655)
+++ gnunet-qt/secushare/preferences/preferences.h 2015-11-12 18:30:41 UTC
(rev 36656)
@@ -27,90 +27,83 @@
#include <QStandardPaths>
#include <QDir>
-class Preferences : public QSettings
+class Preferences:public QSettings
{
- Q_OBJECT
- Q_DISABLE_COPY (Preferences)
+ Q_OBJECT Q_DISABLE_COPY (Preferences)
+ /*
+ * GENERAL
+ */
+Q_PROPERTY (bool minimizeToTray READ minimizeToTray WRITE setMinimizeToTray
NOTIFY minimizeToTrayChangedSignal) Q_PROPERTY (QString name READ name WRITE
setName NOTIFY nameChangedSignal) Q_PROPERTY (QString status READ status WRITE
setStatus NOTIFY statusChangedSignal) Q_PROPERTY (bool saveRoom READ saveRoom
WRITE setSaveRoom NOTIFY saveRoomChangedSignal) public:
+ explicit Preferences (QObject * parent =
+ 0);
- /*
- * GENERAL
- */
- Q_PROPERTY(bool minimizeToTray READ minimizeToTray WRITE setMinimizeToTray
NOTIFY minimizeToTrayChangedSignal)
+ /*
+ * GENERAL
+ */
- Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChangedSignal)
- Q_PROPERTY(QString status READ status WRITE setStatus NOTIFY
statusChangedSignal)
+ bool minimizeToTray ()
+ {
+ return value ("core/minimizeToTray", true).toBool ();
+ }
- Q_PROPERTY(bool saveRoom READ saveRoom WRITE setSaveRoom NOTIFY
saveRoomChangedSignal)
+ void setMinimizeToTray (bool flag)
+ {
+ setValue ("core/minimizeToTray", flag);
+ emit minimizeToTrayChangedSignal (flag);
+ }
-public:
- explicit Preferences(QObject *parent = 0);
+ QString name ()
+ {
+ return value ("core/name", "My Username").toString ();
+ }
- /*
- * GENERAL
- */
+ void setName (QString name)
+ {
+ setValue ("core/name", name);
+ emit nameChangedSignal (name);
+ }
- bool minimizeToTray()
- {
- return value("core/minimizeToTray",true).toBool();
- }
+ QString status ()
+ {
+ return value ("core/status", "My Status").toString ();
+ }
- void setMinimizeToTray(bool flag)
- {
- setValue("core/minimizeToTray",flag);
- emit minimizeToTrayChangedSignal(flag);
- }
+ void setStatus (QString status)
+ {
- QString name()
- {
- return value("core/name","My Username").toString();
- }
+ setValue ("core/status", status);
+ emit statusChangedSignal (status);
+ }
- void setName(QString name)
- {
- setValue("core/name",name);
- emit nameChangedSignal(name);
- }
+ bool saveRoom ()
+ {
+ return value ("core/saveRoom", true).toBool ();
+ }
- QString status()
- {
- return value("core/status","My Status").toString();
- }
+ void setSaveRoom (bool flag)
+ {
+ setValue ("core/saveRoom", flag);
+ emit saveRoomChangedSignal (flag);
+ }
- void setStatus(QString status)
- {
- setValue("core/status",status);
- emit statusChangedSignal(status);
- }
+ Q_INVOKABLE void save ();
- bool saveRoom()
- {
- return value("core/saveRoom",true).toBool();
- }
+ QString getFolder ();
- void setSaveRoom(bool flag)
- {
- setValue("core/saveRoom",flag);
- emit saveRoomChangedSignal(flag);
- }
+signals:
+ /*
+ * GENERAL
+ */
+ void minimizeToTrayChangedSignal (bool flag);
- Q_INVOKABLE void save();
+ void nameChangedSignal (QString name);
- QString getFolder();
-signals:
- /*
- * GENERAL
- */
+ void statusChangedSignal (QString status);
- void minimizeToTrayChangedSignal(bool flag);
- void nameChangedSignal(QString name);
- void statusChangedSignal(QString status);
- void saveRoomChangedSignal(bool flag);
+ void saveRoomChangedSignal (bool flag);
-public slots:
+public slots:};
-
-};
-
#endif // PREFERENCES_H
Modified: gnunet-qt/secushare/psyc.cpp
===================================================================
--- gnunet-qt/secushare/psyc.cpp 2015-11-12 18:30:37 UTC (rev 36655)
+++ gnunet-qt/secushare/psyc.cpp 2015-11-12 18:30:41 UTC (rev 36656)
@@ -21,56 +21,79 @@
/* Static member variables */
-Preferences* thePrefs;
-QQuickWindow* theWindow;
+Preferences *thePrefs;
+QQuickWindow *theWindow;
+
#define URI "Psyc"
-Psyc::Psyc(QObject *parent) :
- QObject(parent)
+Psyc::Psyc (QObject * parent):
+QObject (parent)
{
- thePrefs = new Preferences(this);
- m_core = new PsycCore(this);
- registerQmlTypes();
+ thePrefs = new Preferences (this);
+ m_core = new PsycCore (this);
+ registerQmlTypes ();
}
//Define the theApp singleton type provider.
-static QObject *theApp_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
+static QObject *
+theApp_provider (QQmlEngine * engine, QJSEngine * scriptEngine)
{
- Q_UNUSED(engine);
- Q_UNUSED(scriptEngine);
+ Q_UNUSED (engine);
+ Q_UNUSED (scriptEngine);
- return theApp;
+ return theApp;
}
-static QObject *thePrefs_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
+static QObject *
+thePrefs_provider (QQmlEngine * engine, QJSEngine * scriptEngine)
{
- Q_UNUSED(engine);
- Q_UNUSED(scriptEngine);
+ Q_UNUSED (engine);
+ Q_UNUSED (scriptEngine);
- return thePrefs;
+ return thePrefs;
}
-void Psyc::registerQmlTypes()
+void
+Psyc::registerQmlTypes ()
{
- qmlRegisterSingletonType<PsycCore>(URI, 1, 0, "Preferences",
thePrefs_provider);
- qmlRegisterSingletonType<PsycCore>(URI, 1, 0, "Psyc", theApp_provider);
+ qmlRegisterSingletonType < PsycCore > (URI, 1, 0, "Preferences",
+ thePrefs_provider);
+ qmlRegisterSingletonType < PsycCore > (URI, 1, 0, "Psyc", theApp_provider);
- qmlRegisterUncreatableType<Models>(URI, 1, 0, "Models", QLatin1String("Use
calling the psyc method."));
- qmlRegisterUncreatableType<PlacesModel>(URI, 1, 0, "PlacesModel",
QLatin1String("Use calling the psyc method."));
- qmlRegisterUncreatableType<IdentityModel>(URI, 1, 0, "IdentityModel",
QLatin1String("Use calling the psyc method."));
+ qmlRegisterUncreatableType < Models > (URI, 1, 0, "Models",
+ QLatin1String
+ ("Use calling the psyc method."));
+ qmlRegisterUncreatableType < PlacesModel > (URI, 1, 0, "PlacesModel",
+ QLatin1String
+ ("Use calling the psyc
method."));
+ qmlRegisterUncreatableType < IdentityModel > (URI, 1, 0, "IdentityModel",
+ QLatin1String
+ ("Use calling the psyc
method."));
- qmlRegisterUncreatableType<GNUNet>(URI, 1, 0, "GNUNet", QLatin1String("Use
calling the psyc method."));
- qmlRegisterUncreatableType<Helpers>(URI, 1, 0, "Helpers",
QLatin1String("Use calling the psyc method."));
+ qmlRegisterUncreatableType < GNUNet > (URI, 1, 0, "GNUNet",
+ QLatin1String
+ ("Use calling the psyc method."));
+ qmlRegisterUncreatableType < Helpers > (URI, 1, 0, "Helpers",
+ QLatin1String
+ ("Use calling the psyc method."));
- qmlRegisterUncreatableType<IdentityService>(URI, 1, 0, "IdentityService",
QLatin1String("Use calling the psyc method."));
- qmlRegisterUncreatableType<Identity>(URI, 1, 0, "Identity",
QLatin1String("Use calling the psyc method."));
- qmlRegisterUncreatableType<SocialService>(URI, 1, 0, "SocialService",
QLatin1String("Use calling the psyc method."));
- qmlRegisterUncreatableType<Place>(URI, 1, 0, "Place", QLatin1String("Use
calling the psyc method."));
+ qmlRegisterUncreatableType < IdentityService > (URI, 1, 0, "IdentityService",
+ QLatin1String
+ ("Use calling the psyc
method."));
+ qmlRegisterUncreatableType < Identity > (URI, 1, 0, "Identity",
+ QLatin1String
+ ("Use calling the psyc method."));
+ qmlRegisterUncreatableType < SocialService > (URI, 1, 0, "SocialService",
+ QLatin1String
+ ("Use calling the psyc
method."));
+ qmlRegisterUncreatableType < Place > (URI, 1, 0, "Place",
+ QLatin1String
+ ("Use calling the psyc method."));
}
/**
@@ -77,7 +100,8 @@
* @brief Psyc::registerImageProvider , registers image handlers to QML engine
* @param engine
*/
-void Psyc::registerImageProvider(QQmlEngine *engine)
+void
+Psyc::registerImageProvider (QQmlEngine * engine)
{
- engine->addImageProvider("qrProvider",theApp->qrProvider());
+ engine->addImageProvider ("qrProvider", theApp->qrProvider ());
}
Modified: gnunet-qt/secushare/psyc.h
===================================================================
--- gnunet-qt/secushare/psyc.h 2015-11-12 18:30:37 UTC (rev 36655)
+++ gnunet-qt/secushare/psyc.h 2015-11-12 18:30:41 UTC (rev 36656)
@@ -4,24 +4,25 @@
#include <QObject>
class Preferences;
+
class QQuickWindow;
+
class PsycCore;
+
class QQmlEngine;
-class Psyc : public QObject
+
+class Psyc:public QObject
{
- Q_OBJECT
-public:
- explicit Psyc(QObject *parent = 0);
- void registerQmlTypes();
- void registerImageProvider(QQmlEngine *engine);
+Q_OBJECT public:
+ explicit Psyc (QObject * parent = 0);
+ void registerQmlTypes ();
+ void registerImageProvider (QQmlEngine * engine);
private:
- PsycCore *m_core;
+ PsycCore * m_core;
-signals:
+ signals:public slots:};
-public slots:
+extern Preferences *thePrefs;
-};
-extern Preferences* thePrefs;
-extern QQuickWindow* theWindow;
+extern QQuickWindow *theWindow;
#endif // PSYC_H
Modified: gnunet-qt/secushare/utils/helpers.cpp
===================================================================
--- gnunet-qt/secushare/utils/helpers.cpp 2015-11-12 18:30:37 UTC (rev
36655)
+++ gnunet-qt/secushare/utils/helpers.cpp 2015-11-12 18:30:41 UTC (rev
36656)
@@ -6,85 +6,105 @@
#include <QtQuick/QQuickImageProvider>
#include <qrencode.h>
-Helpers::Helpers(QObject *parent) :
- QObject(parent)
+Helpers::Helpers (QObject * parent):
+QObject (parent)
{
}
-QImage Helpers::convertQmlToImage( const QString& path)
+QImage
+Helpers::convertQmlToImage (const QString & path)
{
- QUrl imageUrl(path);
- QQmlEngine* engine = QQmlEngine::contextForObject(this)->engine();
- QQmlImageProviderBase* imageProviderBase = engine->imageProvider(
- imageUrl.host());
- QQuickImageProvider* imageProvider = static_cast<QQuickImageProvider*>
- (imageProviderBase);
+ QUrl imageUrl (path);
- QSize imageSize;
- QString imageId = imageUrl.path().remove(0,1);
- QImage image = imageProvider->requestImage(imageId, &imageSize, imageSize);
+ QQmlEngine *engine = QQmlEngine::contextForObject (this)->engine ();
- return image;
+ QQmlImageProviderBase *imageProviderBase =
+ engine->imageProvider (imageUrl.host ());
+ QQuickImageProvider *imageProvider =
+ static_cast < QQuickImageProvider * >(imageProviderBase);
+ QSize imageSize;
+
+ QString imageId = imageUrl.path ().remove (0, 1);
+
+ QImage image = imageProvider->requestImage (imageId, &imageSize, imageSize);
+
+ return image;
+
}
-QImage Helpers::convertQrToImage(QString str)
+QImage
+Helpers::convertQrToImage (QString str)
{
- QString uri = str;
- //qDebug() << "Encoding:" << uri.toUtf8().constData();
+ QString uri = str;
+ //qDebug() << "Encoding:" << uri.toUtf8().constData();
- QRcode *code = QRcode_encodeString(uri.toUtf8().constData(), 0,
QR_ECLEVEL_L, QR_MODE_8, 1);
- QImage myImage = QImage(code->width + 2, code->width + 2,
QImage::Format_RGB32);
- myImage.fill(0xffffff);
- unsigned char *p = code->data;
- for(int y = 0; y < code->width; y++) {
- for(int x = 0; x < code->width; x++) {
- myImage.setPixel(x + 1, y + 1, ((*p & 1) ? 0x0 : 0xffffff));
- p++;
- }
+
+ QRcode *code =
+ QRcode_encodeString (uri.toUtf8 ().constData (), 0, QR_ECLEVEL_L,
+ QR_MODE_8, 1);
+ QImage myImage =
+ QImage (code->width + 2, code->width + 2, QImage::Format_RGB32);
+ myImage.fill (0xffffff);
+ unsigned char *p = code->data;
+
+ for (int y = 0; y < code->width; y++)
+ {
+ for (int x = 0; x < code->width; x++)
+ {
+ myImage.setPixel (x + 1, y + 1, ((*p & 1) ? 0x0 : 0xffffff));
+ p++;
}
+ }
- QRcode_free(code);
+ QRcode_free (code);
- return myImage;
+ return myImage;
}
-void Helpers::saveQrAsFile(QString path)
+void
+Helpers::saveQrAsFile (QString path)
{
- QImage image = convertQrToImage(theApp->identity()->url());
+ QImage image = convertQrToImage (theApp->identity ()->url ());
- int width = 200;
- int height = 200;
+ int width = 200;
+ int height = 200;
- QSize size = QSize(width, height);
- QImage scaledImage = image.scaled(size);
+ QSize size = QSize (width, height);
- if(!scaledImage.save(path))
- {
- qDebug() << "Fail saving QR code";
- }
+ QImage scaledImage = image.scaled (size);
+
+ if (!scaledImage.save (path))
+ {
+ qDebug () << "Fail saving QR code";
+ }
}
-QString Helpers::importLocation() const
+QString
+Helpers::importLocation () const const
{
- QString imageLocation =
QStandardPaths::writableLocation(QStandardPaths::TempLocation);
+ QString imageLocation =
+ QStandardPaths::writableLocation (QStandardPaths::TempLocation);
- return imageLocation + "/tempQrImage.jpg";
+ return imageLocation + "/tempQrImage.jpg";
}
-bool Helpers::removeTemp()
+bool
+Helpers::removeTemp ()
{
- const char* location = importLocation().toUtf8();
- if(QFile::remove(location) != true ) {
- qWarning() << "Error deleting temporary image";
- }
- return 0;
+ const char *location = importLocation ().toUtf8 ();
+
+ if (QFile::remove (location) != true)
+ {
+ qWarning () << "Error deleting temporary image";
+ }
+ return 0;
}
Modified: gnunet-qt/secushare/utils/helpers.h
===================================================================
--- gnunet-qt/secushare/utils/helpers.h 2015-11-12 18:30:37 UTC (rev 36655)
+++ gnunet-qt/secushare/utils/helpers.h 2015-11-12 18:30:41 UTC (rev 36656)
@@ -4,21 +4,16 @@
#include <QObject>
#include <QImage>
-class Helpers : public QObject
+class Helpers:public QObject
{
- Q_OBJECT
-public:
- explicit Helpers(QObject *parent = 0);
+Q_OBJECT public:
+ explicit Helpers (QObject * parent = 0);
- Q_INVOKABLE QImage convertQmlToImage(const QString &path);
- Q_INVOKABLE QString importLocation() const;
- Q_INVOKABLE bool removeTemp();
- QImage convertQrToImage(QString str);
- Q_INVOKABLE void saveQrAsFile(QString path);
-signals:
+ Q_INVOKABLE QImage convertQmlToImage (const QString & path);
+ Q_INVOKABLE QString importLocation () const;
+ Q_INVOKABLE bool removeTemp ();
+ QImage convertQrToImage (QString str);
+ Q_INVOKABLE void saveQrAsFile (QString path);
+ signals:public slots:};
-public slots:
-
-};
-
#endif // HELPERS_H
Modified: gnunet-qt/secushare/utils/qrimageprovider.cpp
===================================================================
--- gnunet-qt/secushare/utils/qrimageprovider.cpp 2015-11-12 18:30:37 UTC
(rev 36655)
+++ gnunet-qt/secushare/utils/qrimageprovider.cpp 2015-11-12 18:30:41 UTC
(rev 36656)
@@ -6,23 +6,28 @@
#include <QImage>
-QrImageProvider::QrImageProvider():
QQuickImageProvider(QQuickImageProvider::Image)
+QrImageProvider::QrImageProvider ():QQuickImageProvider (QQuickImageProvider::
+ Image)
{
}
-QImage QrImageProvider::requestImage(const QString &id, QSize *size, const
QSize& requestedSize)
+QImage
+QrImageProvider::requestImage (const QString & id, QSize * size,
+ const QSize & requestedSize)
{
- QImage image =
theApp->helpers()->convertQrToImage(theApp->identity()->url());
+ QImage image =
+ theApp->helpers ()->convertQrToImage (theApp->identity ()->url ());
- int width = 200;
- int height = 200;
+ int width = 200;
+ int height = 200;
- if (size)
- *size = QSize(width, height);
- QImage scaledImage = image.scaled(*size);
+ if (size)
+ *size = QSize (width, height);
- return scaledImage;
+ QImage scaledImage = image.scaled (*size);
+
+ return scaledImage;
}
Modified: gnunet-qt/secushare/utils/qrimageprovider.h
===================================================================
--- gnunet-qt/secushare/utils/qrimageprovider.h 2015-11-12 18:30:37 UTC (rev
36655)
+++ gnunet-qt/secushare/utils/qrimageprovider.h 2015-11-12 18:30:41 UTC (rev
36656)
@@ -4,16 +4,13 @@
#include <QQuickImageProvider>
-class QrImageProvider : public QQuickImageProvider
+class QrImageProvider:public QQuickImageProvider
{
public:
- explicit QrImageProvider();
+ explicit QrImageProvider ();
- virtual QImage requestImage(const QString &id, QSize *size, const QSize&
requestedSize);
-signals:
+ virtual QImage requestImage (const QString & id, QSize * size,
+ const QSize & requestedSize);
+ signals:public slots:};
-public slots:
-
-};
-
#endif // QRIMAGEPROVIDER_H
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r36656 - in gnunet-qt/secushare: . core core/gnunet core/identity core/social models preferences utils,
gnunet <=