[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r36659 - in gnunet-qt/secushare: core/identity core/social
From: |
gnunet |
Subject: |
[GNUnet-SVN] r36659 - in gnunet-qt/secushare: core/identity core/social models preferences qml |
Date: |
Thu, 12 Nov 2015 22:44:19 +0100 |
Author: tg
Date: 2015-11-12 22:44:19 +0100 (Thu, 12 Nov 2015)
New Revision: 36659
Modified:
gnunet-qt/secushare/core/identity/identity.h
gnunet-qt/secushare/core/identity/identityService.cpp
gnunet-qt/secushare/core/social/place.h
gnunet-qt/secushare/core/social/socialservice.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/preferences/preferences.cpp
gnunet-qt/secushare/qml/GroupConversation.qml
Log:
use pubkey in identity path
Modified: gnunet-qt/secushare/core/identity/identity.h
===================================================================
--- gnunet-qt/secushare/core/identity/identity.h 2015-11-12 18:30:45 UTC
(rev 36658)
+++ gnunet-qt/secushare/core/identity/identity.h 2015-11-12 21:44:19 UTC
(rev 36659)
@@ -6,10 +6,15 @@
class Identity:public QObject
{
-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);
+ Q_OBJECT;
+ Q_PROPERTY (QString name READ name WRITE setName NOTIFY nameChanged);
+ Q_PROPERTY (QString key READ key);
+ Q_PROPERTY (QString url READ url CONSTANT);
+ public:
+
+ explicit Identity (QString key, QObject * parent = 0);
+
//Index
int getIndex () const
{
@@ -20,7 +25,6 @@
m_index = index;
}
-
QString name ()
{
return m_name;
@@ -33,6 +37,11 @@
emit modifiedSignal (m_index);
}
+ QString key ()
+ {
+ return m_key;
+ }
+
QString url ()
{
return QString ("GNUNET://GNS/%1/").arg (m_key);
Modified: gnunet-qt/secushare/core/identity/identityService.cpp
===================================================================
--- gnunet-qt/secushare/core/identity/identityService.cpp 2015-11-12
18:30:45 UTC (rev 36658)
+++ gnunet-qt/secushare/core/identity/identityService.cpp 2015-11-12
21:44:19 UTC (rev 36659)
@@ -98,13 +98,13 @@
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);
+ char *pubKey = GNUNET_CRYPTO_ecdsa_public_key_to_string (&pub);
- QString strId = QString::fromLatin1 (id);
+ QString strPubKey = QString::fromLatin1 (pubKey);
QString strName = QString::fromLatin1 (name);
- identity = theApp->models ()->identityModel ()->add (strId, strName, ego);
+ identity = theApp->models ()->identityModel ()->add (strPubKey, strName,
ego);
*ego_ctx = identity;
}
Modified: gnunet-qt/secushare/core/social/place.h
===================================================================
--- gnunet-qt/secushare/core/social/place.h 2015-11-12 18:30:45 UTC (rev
36658)
+++ gnunet-qt/secushare/core/social/place.h 2015-11-12 21:44:19 UTC (rev
36659)
@@ -5,10 +5,16 @@
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 key READ key);
+ Q_PROPERTY (QString content READ content NOTIFY contentChanged);
+
+ public:
+
+ explicit Place (QString key, QObject * parent = 0);
+
//Index
int getIndex () const
{
@@ -30,6 +36,12 @@
emit nameChanged (name);
}
+ //Key
+ QString key () const
+ {
+ return m_key;
+ }
+
//Type
QString type () const
{
@@ -68,7 +80,6 @@
return m_content;
}
-
//Slicer
struct GNUNET_SOCIAL_Slicer *slicer () const
{
@@ -102,7 +113,6 @@
return m_placeKey;
}
-
void setPrivateKey (struct GNUNET_CRYPTO_EddsaPrivateKey *key)
{
m_placeKey = key;
@@ -118,8 +128,6 @@
m_placePubKey = key;
}
-
-
Q_INVOKABLE void copyToClipboard ();
Q_INVOKABLE void talk (QString text);
Modified: gnunet-qt/secushare/core/social/socialservice.cpp
===================================================================
--- gnunet-qt/secushare/core/social/socialservice.cpp 2015-11-12 18:30:45 UTC
(rev 36658)
+++ gnunet-qt/secushare/core/social/socialservice.cpp 2015-11-12 21:44:19 UTC
(rev 36659)
@@ -18,8 +18,6 @@
SocialService::SocialService (QObject * parent):
QObject (parent)
{
-
-
//Connect slots
connect (this, &SocialService::createPlaceSignal, this,
&SocialService::createPlaceSlot, Qt::QueuedConnection);
@@ -26,12 +24,9 @@
connect (this, &SocialService::enterRoomSignal, this,
&SocialService::enterRoomSlot, Qt::QueuedConnection);
-
}
-
-
/**
* @brief Should be called when the GNUnet service is connected to start
everything
* @param config
@@ -39,18 +34,15 @@
void
SocialService::start (struct GNUNET_CONFIGURATION_Handle *config)
{
-
-
this->m_config = config;
//Grab selected identity at home screen
- Identity *iden = theApp->identity ();
+ Identity *id = theApp->identity ();
- m_hostEgo = iden->ego ();
+ m_hostEgo = id->ego ();
//Load rooms
theApp->models ()->placesModel ()->load ();
-
}
@@ -65,7 +57,6 @@
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Creating a New Place.\n");
-
QString filename = thePrefs->getFolder () + "/places/" + name + ".private";
GNUNET_CRYPTO_EddsaPrivateKey *placeKey =
@@ -76,12 +67,10 @@
GNUNET_CRYPTO_eddsa_key_get_public (placeKey, placePubKey);
char *id = GNUNET_CRYPTO_eddsa_public_key_to_string (placePubKey);
-
QString strId = QString::fromLatin1 (id);
-
Place *newPlace = theApp->models ()->placesModel ()->add (strId);
- newPlace->setName (strId);
+ newPlace->setName (name);
newPlace->setPrivateKey (placeKey);
newPlace->setPublicKey (placePubKey);
@@ -402,9 +391,7 @@
if (result != GNUNET_OK) // Failed conversion
return;
-
Place *newPlace = theApp->models ()->placesModel ()->add (pubKey);
-
newPlace->setName (pubKey);
newPlace->setPublicKey (convertedRoomKey);
Modified: gnunet-qt/secushare/models/IdentityModel.cpp
===================================================================
--- gnunet-qt/secushare/models/IdentityModel.cpp 2015-11-12 18:30:45 UTC
(rev 36658)
+++ gnunet-qt/secushare/models/IdentityModel.cpp 2015-11-12 21:44:19 UTC
(rev 36659)
@@ -59,23 +59,24 @@
else if (index.row () == m_data.count ())
return QString ("<Create>");
+ Identity *id = m_data[index.row ()];
- Identity *iden = m_data[index.row ()];
-
-
switch (role)
{
case NAME:
- return iden->name ();
+ return id->name ();
break;
+ case KEY:
+ return id->key ();
+ break;
default:
return QVariant::Invalid;
}
-
return QVariant::Invalid;
}
+
QHash < int, QByteArray >
IdentityModel::roleNames () const
{
@@ -82,8 +83,8 @@
QHash < int, QByteArray > roles;
roles[NAME] = "name";
+ roles[KEY] = "key";
-
return roles;
}
@@ -97,28 +98,29 @@
}
/**
- * @brief PlacesModel::add, add a new place to the model.
+ * @brief IdentityModel::add, add a new identity to the model.
* @param key
- * @return Return the new created place
+ * @param name
+ * @return Return the newly created identity
*/
Identity *
IdentityModel::add (QString key, QString name, struct GNUNET_IDENTITY_Ego *ego)
{
- Identity *iden = new Identity (key);
+ Identity *id = new Identity (key);
- iden->setName (name);
- iden->setEgo (ego);
+ id->setName (name);
+ id->setEgo (ego);
- iden->moveToThread (this->thread ());
- emit addNewIdentitySignal (iden, key);
+ id->moveToThread (this->thread ());
+ emit addNewIdentitySignal (id, key);
- return iden;
+ return id;
}
/**
- * @brief PlacesModel::addNewPeerSlot
- * @param key, the place ID.
+ * @brief IdentityModel::addNewIdentitySlot
+ * @param key, the identity key.
* @return return the same place as item
*/
Identity *
@@ -155,9 +157,9 @@
{
if (m_lookupIndex.contains (key))
{
- Identity *iden = m_data[m_lookupIndex[key]];
+ Identity *id = m_data[m_lookupIndex[key]];
- return iden;
+ return id;
}
else
@@ -181,12 +183,12 @@
if (getCount () <= index)
return NULL;
- Identity *iden = m_data[index];
+ Identity *id = m_data[index];
//Set he ownership so QML don't delete it.
- QQmlEngine::setObjectOwnership (iden, QQmlEngine::CppOwnership);
+ QQmlEngine::setObjectOwnership (id, QQmlEngine::CppOwnership);
- return iden;
+ return id;
}
int
Modified: gnunet-qt/secushare/models/IdentityModel.h
===================================================================
--- gnunet-qt/secushare/models/IdentityModel.h 2015-11-12 18:30:45 UTC (rev
36658)
+++ gnunet-qt/secushare/models/IdentityModel.h 2015-11-12 21:44:19 UTC (rev
36659)
@@ -27,17 +27,19 @@
class Identity;
-class IdentityModel:public QAbstractListModel
+class IdentityModel : public QAbstractListModel
{
Q_OBJECT public:
enum IdentityRoles
- { NAME = Qt::UserRole + 1, NB_PLACE_COLUMNS };
+ {
+ NAME = Qt::UserRole + 1,
+ KEY,
+ NB_PLACE_COLUMNS
+ };
-
public:
- explicit IdentityModel (QObject * parent = 0);
+ explicit IdentityModel (QObject * parent = 0);
-
Identity *add (QString key, QString name, struct GNUNET_IDENTITY_Ego *ego);
Q_INVOKABLE int getCount ();
bool contains (QString id);
Modified: gnunet-qt/secushare/models/PlacesModel.cpp
===================================================================
--- gnunet-qt/secushare/models/PlacesModel.cpp 2015-11-12 18:30:45 UTC (rev
36658)
+++ gnunet-qt/secushare/models/PlacesModel.cpp 2015-11-12 21:44:19 UTC (rev
36659)
@@ -37,9 +37,9 @@
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::addNewPlaceSignal, this,
&PlacesModel::addNewPlaceSlot, Qt::BlockingQueuedConnection);
+ connect (this, &PlacesModel::addNewPlaceSignal, this,
+ &PlacesModel::addNewPlaceSlot);
}
@@ -74,7 +74,6 @@
{
out << place->name ();
out << place->isHost ();
-
}
}
@@ -135,18 +134,21 @@
if (index.row () < 0 || index.row () >= m_data.count ())
return QVariant ();
- Place *peer = m_data[index.row ()];
+ Place *place = m_data[index.row ()];
switch (role)
{
case NAME:
- return peer->name ();
+ return place->name ();
break;
+ case KEY:
+ return place->key ();
+ break;
case TYPE:
- return peer->type ();
+ return place->type ();
break;
case STATUS:
- return peer->status ();
+ return place->status ();
break;
default:
return QVariant::Invalid;
@@ -162,6 +164,7 @@
QHash < int, QByteArray > roles;
roles[NAME] = "name";
+ roles[KEY] = "key";
roles[TYPE] = "type";
roles[STATUS] = "status";
@@ -186,22 +189,22 @@
Place *
PlacesModel::add (QString key)
{
- Place *peer = new Place (key);
+ Place *place = new Place (key);
- peer->moveToThread (this->thread ());
- emit addNewPeerSignal (peer, key);
+ place->moveToThread (this->thread ());
+ emit addNewPlaceSignal (place, key);
- return peer;
+ return place;
}
/**
- * @brief PlacesModel::addNewPeerSlot
+ * @brief PlacesModel::addNewPlaceSlot
* @param key, the place ID.
* @return return the same place as item
*/
Place *
-PlacesModel::addNewPeerSlot (Place * item, QString key)
+PlacesModel::addNewPlaceSlot (Place * item, QString key)
{
//Search if already exists
@@ -235,9 +238,9 @@
{
if (m_lookupIndex.contains (key))
{
- Place *peer = m_data[m_lookupIndex[key]];
+ Place *place = m_data[m_lookupIndex[key]];
- return peer;
+ return place;
}
else
@@ -261,12 +264,12 @@
if (getCount () < index)
return NULL;
- Place *peer = m_data[index];
+ Place *place = m_data[index];
//Set he ownership so QML don't delete it.
- QQmlEngine::setObjectOwnership (peer, QQmlEngine::CppOwnership);
+ QQmlEngine::setObjectOwnership (place, QQmlEngine::CppOwnership);
- return peer;
+ return place;
}
Modified: gnunet-qt/secushare/models/PlacesModel.h
===================================================================
--- gnunet-qt/secushare/models/PlacesModel.h 2015-11-12 18:30:45 UTC (rev
36658)
+++ gnunet-qt/secushare/models/PlacesModel.h 2015-11-12 21:44:19 UTC (rev
36659)
@@ -29,13 +29,20 @@
class PlacesModel:public QAbstractListModel
{
-Q_OBJECT public:
+ Q_OBJECT;
+
+public:
enum PlaceRoles
- { NAME = Qt::UserRole + 1, TYPE, STATUS, NB_PLACE_COLUMNS };
+ {
+ NAME = Qt::UserRole + 1,
+ KEY,
+ TYPE,
+ STATUS,
+ NB_PLACE_COLUMNS
+ };
-
public:
- explicit PlacesModel (QObject * parent = 0);
+ explicit PlacesModel (QObject * parent = 0);
struct Bandwidth_Info_Struct *getTotalBandwidth ();
Place *add (QString key);
@@ -48,24 +55,20 @@
void save ();
void load ();
- ~PlacesModel ();
- signals:void addNewPeerSignal (Place * item, QString key);
+ ~PlacesModel ();
+signals:
+ void addNewPlaceSignal (Place * item, QString key);
+
public slots:void modifiedSlot (int indexRow);
- private slots:Place * addNewPeerSlot (Place * item, QString name);
+ private slots:Place * addNewPlaceSlot (Place * item, QString name);
-
private:
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 < int, QByteArray > roleNames () const;
+ QHash < QString, int >m_lookupIndex;
+ QList < Place * >m_data;
};
#endif // PLACESMODEL_H
Modified: gnunet-qt/secushare/preferences/preferences.cpp
===================================================================
--- gnunet-qt/secushare/preferences/preferences.cpp 2015-11-12 18:30:45 UTC
(rev 36658)
+++ gnunet-qt/secushare/preferences/preferences.cpp 2015-11-12 21:44:19 UTC
(rev 36659)
@@ -28,8 +28,9 @@
#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 ();
}
@@ -51,7 +52,7 @@
QString fileDirStr = fileDir.absolutePath ();
- Identity *iden = theApp->identity ();
+ Identity *id = theApp->identity ();
- return fileDirStr + "/" + applicationName () + "/" + iden->name ();
+ return fileDirStr + "/" + applicationName () + "/" + id->key ();
}
Modified: gnunet-qt/secushare/qml/GroupConversation.qml
===================================================================
--- gnunet-qt/secushare/qml/GroupConversation.qml 2015-11-12 18:30:45 UTC
(rev 36658)
+++ gnunet-qt/secushare/qml/GroupConversation.qml 2015-11-12 21:44:19 UTC
(rev 36659)
@@ -52,7 +52,7 @@
id: description
anchors.left: name.left
anchors.top: name.bottom
- text: qsTr("Look at my group, my group is amazing !")
+ text: place.key
font.pointSize: 10
color: "darkgrey"
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r36659 - in gnunet-qt/secushare: core/identity core/social models preferences qml,
gnunet <=