aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client/CMakeLists.txt2
-rw-r--r--client/src/service/connection_manager.vala2
-rw-r--r--client/src/service/message_manager.vala2
-rw-r--r--vala-xmpp/CMakeLists.txt3
-rw-r--r--vala-xmpp/src/core/stanza_writer.vala2
-rw-r--r--vala-xmpp/src/module/iq/stanza.vala8
-rw-r--r--vala-xmpp/src/module/message/stanza.vala4
-rw-r--r--vala-xmpp/src/module/presence/stanza.vala4
-rw-r--r--vala-xmpp/src/module/roster/module.vala2
-rw-r--r--vala-xmpp/src/module/util.vala8
-rw-r--r--vala-xmpp/vapi/uuid.vapi (renamed from vapi/uuid.vapi)8
11 files changed, 21 insertions, 24 deletions
diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt
index ac42ecff..1ce8c1ee 100644
--- a/client/CMakeLists.txt
+++ b/client/CMakeLists.txt
@@ -1,7 +1,6 @@
find_package(Vala REQUIRED)
find_package(PkgConfig REQUIRED)
find_package(GPGME REQUIRED)
-find_package(LIBUUID REQUIRED)
include(${VALA_USE_FILE})
include(GlibCompileResourcesSupport)
@@ -127,7 +126,6 @@ SOURCES
PACKAGES
${CLIENT_PACKAGES}
gpgme
- uuid
vala-xmpp
qlite
GRESOURCES
diff --git a/client/src/service/connection_manager.vala b/client/src/service/connection_manager.vala
index 91664af5..75155e98 100644
--- a/client/src/service/connection_manager.vala
+++ b/client/src/service/connection_manager.vala
@@ -136,7 +136,7 @@ public class ConnectionManager {
print(@"recovering in $wait_sec\n");
Timeout.add_seconds(wait_sec, () => {
if (stream_error_flag.resource_rejected) {
- connect_(account, account.resourcepart + "-" + UUID.generate_random_unparsed());
+ connect_(account, account.resourcepart + "-" + random_uuid());
} else {
connect_(account);
}
diff --git a/client/src/service/message_manager.vala b/client/src/service/message_manager.vala
index 054db518..ec7a35c8 100644
--- a/client/src/service/message_manager.vala
+++ b/client/src/service/message_manager.vala
@@ -141,7 +141,7 @@ public class MessageManager : StreamInteractionModule, Object {
private Entities.Message create_out_message(string text, Conversation conversation) {
Entities.Message message = new Entities.Message();
- message.stanza_id = UUID.generate_random_unparsed();
+ message.stanza_id = random_uuid();
message.account = conversation.account;
message.body = text;
message.time = new DateTime.now_utc();
diff --git a/vala-xmpp/CMakeLists.txt b/vala-xmpp/CMakeLists.txt
index 3278d9c2..e7be66ae 100644
--- a/vala-xmpp/CMakeLists.txt
+++ b/vala-xmpp/CMakeLists.txt
@@ -64,10 +64,11 @@ SOURCES
"src/module/xep/0280_message_carbons.vala"
"src/module/xep/0333_chat_markers.vala"
"src/module/xep/pixbuf_storage.vala"
+CUSTOM_VAPIS
+ "${CMAKE_CURRENT_SOURCE_DIR}/vapi/uuid.vapi"
PACKAGES
${ENGINE_PACKAGES}
gpgme
- uuid
GENERATE_VAPI
vala-xmpp
GENERATE_HEADER
diff --git a/vala-xmpp/src/core/stanza_writer.vala b/vala-xmpp/src/core/stanza_writer.vala
index 625f42e2..26524d7b 100644
--- a/vala-xmpp/src/core/stanza_writer.vala
+++ b/vala-xmpp/src/core/stanza_writer.vala
@@ -2,8 +2,6 @@ namespace Xmpp.Core {
public class StanzaWriter {
private OutputStream output;
- private NamespaceState ns_state = new NamespaceState();
-
public StanzaWriter.for_stream(OutputStream output) {
this.output = output;
}
diff --git a/vala-xmpp/src/module/iq/stanza.vala b/vala-xmpp/src/module/iq/stanza.vala
index 99d589ff..561c5866 100644
--- a/vala-xmpp/src/module/iq/stanza.vala
+++ b/vala-xmpp/src/module/iq/stanza.vala
@@ -10,12 +10,12 @@ public class Stanza : Xmpp.Stanza {
public const string TYPE_RESULT = "result";
public const string TYPE_SET = "set";
- private Stanza(string id = UUID.generate_random_unparsed()) {
+ private Stanza(string? id = null) {
base.outgoing(new StanzaNode.build("iq"));
- this.id = id;
+ this.id = id ?? random_uuid();
}
- public Stanza.get(StanzaNode stanza_node, string id = UUID.generate_random_unparsed()) {
+ public Stanza.get(StanzaNode stanza_node, string? id = null) {
this(id);
this.type_ = TYPE_GET;
stanza.put_node(stanza_node);
@@ -29,7 +29,7 @@ public class Stanza : Xmpp.Stanza {
}
}
- public Stanza.set(StanzaNode stanza_node, string id = UUID.generate_random_unparsed()) {
+ public Stanza.set(StanzaNode stanza_node, string? id = null) {
this(id);
type_ = TYPE_SET;
stanza.put_node(stanza_node);
diff --git a/vala-xmpp/src/module/message/stanza.vala b/vala-xmpp/src/module/message/stanza.vala
index 811fbd22..8a9064a5 100644
--- a/vala-xmpp/src/module/message/stanza.vala
+++ b/vala-xmpp/src/module/message/stanza.vala
@@ -33,9 +33,9 @@ public class Stanza : Xmpp.Stanza {
}
}
- public Stanza(string id = UUID.generate_random_unparsed()) {
+ public Stanza(string? id = null) {
base.outgoing(new StanzaNode.build("message"));
- stanza.set_attribute(ATTRIBUTE_ID, id);
+ stanza.set_attribute(ATTRIBUTE_ID, id ?? random_uuid());
}
public Stanza.from_stanza(StanzaNode stanza_node, string my_jid) {
diff --git a/vala-xmpp/src/module/presence/stanza.vala b/vala-xmpp/src/module/presence/stanza.vala
index 3dc036e5..9ad8f791 100644
--- a/vala-xmpp/src/module/presence/stanza.vala
+++ b/vala-xmpp/src/module/presence/stanza.vala
@@ -80,9 +80,9 @@ public class Stanza : Xmpp.Stanza {
set { base.type_ = value; }
}
- public Stanza(string id = UUID.generate_random_unparsed()) {
+ public Stanza(string? id = null) {
stanza = new StanzaNode.build("presence");
- this.id = id;
+ this.id = id ?? random_uuid();
}
public Stanza.from_stanza(StanzaNode stanza_node, string my_jid) {
diff --git a/vala-xmpp/src/module/roster/module.vala b/vala-xmpp/src/module/roster/module.vala
index 9fa23a55..c8b09710 100644
--- a/vala-xmpp/src/module/roster/module.vala
+++ b/vala-xmpp/src/module/roster/module.vala
@@ -95,7 +95,7 @@ namespace Xmpp.Roster {
internal override string get_id() { return ID; }
private void roster_get(XmppStream stream) {
- Flag.get_flag(stream).iq_id = UUID.generate_random_unparsed();
+ Flag.get_flag(stream).iq_id = random_uuid();
StanzaNode query_node = new StanzaNode.build("query", NS_URI).add_self_xmlns();
Iq.Stanza iq = new Iq.Stanza.get(query_node, Flag.get_flag(stream).iq_id);
Iq.Module.get_module(stream).send_iq(stream, iq, new IqResponseListenerImpl());
diff --git a/vala-xmpp/src/module/util.vala b/vala-xmpp/src/module/util.vala
index 4d762883..65a9b261 100644
--- a/vala-xmpp/src/module/util.vala
+++ b/vala-xmpp/src/module/util.vala
@@ -10,4 +10,12 @@ namespace Xmpp {
string? get_resource_part(string jid) {
return jid.split("/")[1];
}
+
+ public string random_uuid() {
+ uint8[] rand = new uint8[16];
+ char[] str = new char[37];
+ UUID.generate_random(rand);
+ UUID.unparse_upper(rand, str);
+ return (string) str;
+ }
} \ No newline at end of file
diff --git a/vapi/uuid.vapi b/vala-xmpp/vapi/uuid.vapi
index 038fcc33..991917a7 100644
--- a/vapi/uuid.vapi
+++ b/vala-xmpp/vapi/uuid.vapi
@@ -57,12 +57,4 @@ namespace UUID {
// public static time_t time ([CCode (array_length = false)] uint8 uu[16], out Posix.timeval ret_tv);
public static UUID.Type type ([CCode (array_length = false)] uint8 uu[16]);
public static UUID.Variant variant ([CCode (array_length = false)] uint8 uu[16]);
-
- public static string generate_random_unparsed() {
- uint8[] rand = new uint8[16];
- char[] str = new char[37];
- generate_random(rand);
- unparse_upper(rand, str);
- return (string) str;
- }
}