Drop libuuid dependency, uuid generation is not that complicated...

This commit is contained in:
Marvin W 2017-03-12 22:23:25 +01:00
parent bd1f116b3a
commit 22c9c53b1d
No known key found for this signature in database
GPG Key ID: 072E9235DB996F2A
5 changed files with 11 additions and 114 deletions

View File

@ -1,42 +0,0 @@
# - Find libuuid
# Find the libuuid library
#
# This module defines the following variables:
# LIBUUID_FOUND - True if library and include directory are found
# If set to TRUE, the following are also defined:
# LIBUUID_INCLUDE_DIRS - The directory where to find the header file
# LIBUUID_LIBRARIES - Where to find the library file
#
# For conveniance, these variables are also set. They have the same values
# than the variables above. The user can thus choose his/her prefered way
# to write them.
# LIBUUID_INCLUDE_DIR
# LIBUUID_LIBRARY
#
# This file is in the public domain
include(FindPkgConfig)
pkg_check_modules(LIBUUID uuid)
if(NOT LIBUUID_FOUND)
find_path(LIBUUID_INCLUDE_DIRS NAMES uuid/uuid.h
PATH_SUFFIXES uuid
DOC "The libuuid include directory")
find_library(LIBUUID_LIBRARIES NAMES uuid
DOC "The libuuid library")
# Use some standard module to handle the QUIETLY and REQUIRED arguments, and
# set LIBUUID_FOUND to TRUE if these two variables are set.
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LIBUUID REQUIRED_VARS LIBUUID_LIBRARIES LIBUUID_INCLUDE_DIRS)
# Compatibility for all the ways of writing these variables
if(LIBUUID_FOUND)
set(LIBUUID_INCLUDE_DIR ${LIBUUID_INCLUDE_DIRS})
set(LIBUUID_LIBRARY ${LIBUUID_LIBRARIES})
set(LIBUUID_CFLAGS -I${LIBUUID_INCLUDE_DIRS})
endif()
endif()
mark_as_advanced(LIBUUID_INCLUDE_DIRS LIBUUID_LIBRARIES LIBUUID_CFLAGS)

View File

@ -23,10 +23,10 @@ public class List : ListBox {
set_sort_func(sort);
ChatInteraction.get_instance(stream_interactor).conversation_read.connect((conversation) => {
Idle.add(() => {rows[conversation].mark_read(); return false;});
Idle.add(() => {if (rows.has_key(conversation)) rows[conversation].mark_read(); return false;});
});
ChatInteraction.get_instance(stream_interactor).conversation_unread.connect((conversation) => {
Idle.add(() => {rows[conversation].mark_unread(); return false;});
Idle.add(() => {if (rows.has_key(conversation)) rows[conversation].mark_unread(); return false;});
});
ConversationManager.get_instance(stream_interactor).conversation_activated.connect((conversation) => {
Idle.add(() => {add_conversation(conversation); return false;});

View File

@ -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

View File

@ -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 {

View File

@ -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]);
}