aboutsummaryrefslogtreecommitdiff
path: root/xmpp-vala
diff options
context:
space:
mode:
Diffstat (limited to 'xmpp-vala')
-rw-r--r--xmpp-vala/CMakeLists.txt7
-rw-r--r--xmpp-vala/src/module/util.vala12
-rw-r--r--xmpp-vala/vapi/uuid.vapi60
3 files changed, 9 insertions, 70 deletions
diff --git a/xmpp-vala/CMakeLists.txt b/xmpp-vala/CMakeLists.txt
index d1c66726..426f7922 100644
--- a/xmpp-vala/CMakeLists.txt
+++ b/xmpp-vala/CMakeLists.txt
@@ -1,6 +1,5 @@
find_package(Vala REQUIRED)
find_package(PkgConfig REQUIRED)
-find_package(LIBUUID REQUIRED)
include(GlibCompileResourcesSupport)
include(${VALA_USE_FILE})
@@ -61,8 +60,6 @@ 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}
GENERATE_VAPI
@@ -75,10 +72,10 @@ OPTIONS
--thread
)
-set(CFLAGS ${VALA_CFLAGS} ${ENGINE_CFLAGS} ${GPGME_CFLAGS} ${LIBUUID_CFLAGS})
+set(CFLAGS ${VALA_CFLAGS} ${ENGINE_CFLAGS})
add_definitions(${CFLAGS})
add_library(xmpp-vala SHARED ${ENGINE_VALA_C})
-target_link_libraries(xmpp-vala ${ENGINE_LIBRARIES} ${GPGME_LIBRARIES} ${LIBUUID_LIBRARIES})
+target_link_libraries(xmpp-vala ${ENGINE_LIBRARIES})
add_custom_target(xmpp-vala-vapi
DEPENDS
diff --git a/xmpp-vala/src/module/util.vala b/xmpp-vala/src/module/util.vala
index 7e1bb2b3..9096ea32 100644
--- a/xmpp-vala/src/module/util.vala
+++ b/xmpp-vala/src/module/util.vala
@@ -12,11 +12,13 @@ namespace Xmpp {
}
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;
+ uint32 b1 = Random.next_int();
+ uint16 b2 = (uint16)Random.next_int();
+ uint16 b3 = (uint16)(Random.next_int() | 0x4000u) & ~0xb000u;
+ uint16 b4 = (uint16)(Random.next_int() | 0x8000u) & ~0x4000u;
+ uint16 b5_1 = (uint16)Random.next_int();
+ uint32 b5_2 = Random.next_int();
+ return "%08x-%04x-%04x-%04x-%04x%08x".printf(b1, b2, b3, b4, b5_1, b5_2);
}
public class Tuple<A,B> : Object {
diff --git a/xmpp-vala/vapi/uuid.vapi b/xmpp-vala/vapi/uuid.vapi
deleted file mode 100644
index 991917a7..00000000
--- a/xmpp-vala/vapi/uuid.vapi
+++ /dev/null
@@ -1,60 +0,0 @@
-/* libuuid Vala Bindings
- * Copyright 2014 Evan Nemerson <evan@nemerson.com>
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use, copy,
- * modify, merge, publish, distribute, sublicense, and/or sell copies
- * of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-[CCode (cheader_filename = "uuid.h", lower_case_cprefix = "uuid_")]
-namespace UUID {
- [CCode (cname = "int", has_type_id = false)]
- public enum Variant {
- NCS,
- DCE,
- MICROSOFT,
- OTHER
- }
-
- [CCode (cname = "int", has_type_id = false)]
- public enum Type {
- DCE_TIME,
- DCE_RANDOM
- }
-
- public static void clear ([CCode (array_length = false)] uint8 uu[16]);
- public static void copy (uint8 dst[16], uint8 src[16]);
-
- public static void generate ([CCode (array_length = false)] uint8 @out[16]);
- public static void generate_random ([CCode (array_length = false)] uint8 @out[16]);
- public static void generate_time ([CCode (array_length = false)] uint8 @out[16]);
- public static void generate_time_safe ([CCode (array_length = false)] uint8 @out[16]);
-
- public static bool is_null ([CCode (array_length = false)] uint8 uu[16]);
-
- public static int parse (string in, [CCode (array_length = false)] uint8 uu[16]);
-
- public static void unparse ([CCode (array_length = false)] uint8 uu[16], [CCode (array_length = false)] char @out[37]);
- public static void unparse_lower ([CCode (array_length = false)] uint8 uu[16], [CCode (array_length = false)] char @out[37]);
- public static void unparse_upper ([CCode (array_length = false)] uint8 uu[16], [CCode (array_length = false)] char @out[37]);
-
-// 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]);
-}