Do not expose UUID lib dependency outside vala-xmpp library
This commit is contained in:
parent
5fc0435cc1
commit
7a1aa8c806
|
@ -1,7 +1,6 @@
|
||||||
find_package(Vala REQUIRED)
|
find_package(Vala REQUIRED)
|
||||||
find_package(PkgConfig REQUIRED)
|
find_package(PkgConfig REQUIRED)
|
||||||
find_package(GPGME REQUIRED)
|
find_package(GPGME REQUIRED)
|
||||||
find_package(LIBUUID REQUIRED)
|
|
||||||
include(${VALA_USE_FILE})
|
include(${VALA_USE_FILE})
|
||||||
include(GlibCompileResourcesSupport)
|
include(GlibCompileResourcesSupport)
|
||||||
|
|
||||||
|
@ -127,7 +126,6 @@ SOURCES
|
||||||
PACKAGES
|
PACKAGES
|
||||||
${CLIENT_PACKAGES}
|
${CLIENT_PACKAGES}
|
||||||
gpgme
|
gpgme
|
||||||
uuid
|
|
||||||
vala-xmpp
|
vala-xmpp
|
||||||
qlite
|
qlite
|
||||||
GRESOURCES
|
GRESOURCES
|
||||||
|
|
|
@ -136,7 +136,7 @@ public class ConnectionManager {
|
||||||
print(@"recovering in $wait_sec\n");
|
print(@"recovering in $wait_sec\n");
|
||||||
Timeout.add_seconds(wait_sec, () => {
|
Timeout.add_seconds(wait_sec, () => {
|
||||||
if (stream_error_flag.resource_rejected) {
|
if (stream_error_flag.resource_rejected) {
|
||||||
connect_(account, account.resourcepart + "-" + UUID.generate_random_unparsed());
|
connect_(account, account.resourcepart + "-" + random_uuid());
|
||||||
} else {
|
} else {
|
||||||
connect_(account);
|
connect_(account);
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,7 +141,7 @@ public class MessageManager : StreamInteractionModule, Object {
|
||||||
|
|
||||||
private Entities.Message create_out_message(string text, Conversation conversation) {
|
private Entities.Message create_out_message(string text, Conversation conversation) {
|
||||||
Entities.Message message = new Entities.Message();
|
Entities.Message message = new Entities.Message();
|
||||||
message.stanza_id = UUID.generate_random_unparsed();
|
message.stanza_id = random_uuid();
|
||||||
message.account = conversation.account;
|
message.account = conversation.account;
|
||||||
message.body = text;
|
message.body = text;
|
||||||
message.time = new DateTime.now_utc();
|
message.time = new DateTime.now_utc();
|
||||||
|
|
|
@ -64,10 +64,11 @@ SOURCES
|
||||||
"src/module/xep/0280_message_carbons.vala"
|
"src/module/xep/0280_message_carbons.vala"
|
||||||
"src/module/xep/0333_chat_markers.vala"
|
"src/module/xep/0333_chat_markers.vala"
|
||||||
"src/module/xep/pixbuf_storage.vala"
|
"src/module/xep/pixbuf_storage.vala"
|
||||||
|
CUSTOM_VAPIS
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/vapi/uuid.vapi"
|
||||||
PACKAGES
|
PACKAGES
|
||||||
${ENGINE_PACKAGES}
|
${ENGINE_PACKAGES}
|
||||||
gpgme
|
gpgme
|
||||||
uuid
|
|
||||||
GENERATE_VAPI
|
GENERATE_VAPI
|
||||||
vala-xmpp
|
vala-xmpp
|
||||||
GENERATE_HEADER
|
GENERATE_HEADER
|
||||||
|
|
|
@ -2,8 +2,6 @@ namespace Xmpp.Core {
|
||||||
public class StanzaWriter {
|
public class StanzaWriter {
|
||||||
private OutputStream output;
|
private OutputStream output;
|
||||||
|
|
||||||
private NamespaceState ns_state = new NamespaceState();
|
|
||||||
|
|
||||||
public StanzaWriter.for_stream(OutputStream output) {
|
public StanzaWriter.for_stream(OutputStream output) {
|
||||||
this.output = output;
|
this.output = output;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,12 +10,12 @@ public class Stanza : Xmpp.Stanza {
|
||||||
public const string TYPE_RESULT = "result";
|
public const string TYPE_RESULT = "result";
|
||||||
public const string TYPE_SET = "set";
|
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"));
|
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(id);
|
||||||
this.type_ = TYPE_GET;
|
this.type_ = TYPE_GET;
|
||||||
stanza.put_node(stanza_node);
|
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);
|
this(id);
|
||||||
type_ = TYPE_SET;
|
type_ = TYPE_SET;
|
||||||
stanza.put_node(stanza_node);
|
stanza.put_node(stanza_node);
|
||||||
|
|
|
@ -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"));
|
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) {
|
public Stanza.from_stanza(StanzaNode stanza_node, string my_jid) {
|
||||||
|
|
|
@ -80,9 +80,9 @@ public class Stanza : Xmpp.Stanza {
|
||||||
set { base.type_ = value; }
|
set { base.type_ = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public Stanza(string id = UUID.generate_random_unparsed()) {
|
public Stanza(string? id = null) {
|
||||||
stanza = new StanzaNode.build("presence");
|
stanza = new StanzaNode.build("presence");
|
||||||
this.id = id;
|
this.id = id ?? random_uuid();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Stanza.from_stanza(StanzaNode stanza_node, string my_jid) {
|
public Stanza.from_stanza(StanzaNode stanza_node, string my_jid) {
|
||||||
|
|
|
@ -95,7 +95,7 @@ namespace Xmpp.Roster {
|
||||||
internal override string get_id() { return ID; }
|
internal override string get_id() { return ID; }
|
||||||
|
|
||||||
private void roster_get(XmppStream stream) {
|
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();
|
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.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());
|
Iq.Module.get_module(stream).send_iq(stream, iq, new IqResponseListenerImpl());
|
||||||
|
|
|
@ -10,4 +10,12 @@ namespace Xmpp {
|
||||||
string? get_resource_part(string jid) {
|
string? get_resource_part(string jid) {
|
||||||
return jid.split("/")[1];
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -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 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.Type type ([CCode (array_length = false)] uint8 uu[16]);
|
||||||
public static UUID.Variant variant ([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;
|
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
Reference in a new issue