Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
biboumi
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
99
Issues
99
List
Boards
Labels
Service Desk
Milestones
Merge Requests
12
Merge Requests
12
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
louiz’
biboumi
Commits
a63faf6f
Commit
a63faf6f
authored
May 30, 2014
by
louiz’
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use libuuid to generate unique IDs for iq and adhoc sessions
parent
8eb9e535
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
60 additions
and
9 deletions
+60
-9
CMakeLists.txt
CMakeLists.txt
+4
-1
cmake/Modules/FindLibuuid.cmake
cmake/Modules/FindLibuuid.cmake
+41
-0
src/test.cpp
src/test.cpp
+8
-3
src/xmpp/xmpp_component.cpp
src/xmpp/xmpp_component.cpp
+7
-3
src/xmpp/xmpp_component.hpp
src/xmpp/xmpp_component.hpp
+0
-2
No files found.
CMakeLists.txt
View file @
a63faf6f
...
...
@@ -18,6 +18,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
include
(
FindEXPAT
)
find_package
(
EXPAT REQUIRED
)
find_package
(
Iconv REQUIRED
)
find_package
(
Libuuid REQUIRED
)
find_package
(
Libidn
)
find_package
(
SystemdDaemon
)
...
...
@@ -26,6 +27,7 @@ include_directories("${CMAKE_CURRENT_SOURCE_DIR}/src/")
include_directories
(
"
${
CMAKE_CURRENT_BINARY_DIR
}
/src/"
)
include_directories
(
${
EXPAT_INCLUDE_DIRS
}
)
include_directories
(
${
ICONV_INCLUDE_DIRS
}
)
include_directories
(
${
LIBUUID_INCLUDE_DIRS
}
)
if
(
LIBIDN_FOUND
)
include_directories
(
${
LIBIDN_INCLUDE_DIRS
}
)
...
...
@@ -109,7 +111,8 @@ file(GLOB source_xmpp
src/xmpp/*.[hc]pp
)
add_library
(
xmpp STATIC
${
source_xmpp
}
)
target_link_libraries
(
xmpp bridge network utils logger
${
EXPAT_LIBRARIES
}
)
${
EXPAT_LIBRARIES
}
${
LIBUUID_LIBRARIES
}
)
if
(
LIBIDN_FOUND
)
target_link_libraries
(
xmpp
${
LIBIDN_LIBRARIES
}
)
endif
()
...
...
cmake/Modules/FindLibuuid.cmake
0 → 100644
View file @
a63faf6f
# - 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.h
PATH 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
}
)
endif
()
endif
()
mark_as_advanced
(
LIBUUID_INCLUDE_DIRS LIBUUID_LIBRARIES
)
src/test.cpp
View file @
a63faf6f
...
...
@@ -121,9 +121,14 @@ int main()
/**
* Id generation
*/
assert
(
XmppComponent
::
next_id
()
==
"0"
);
assert
(
XmppComponent
::
next_id
()
==
"1"
);
assert
(
XmppComponent
::
next_id
()
==
"2"
);
std
::
cout
<<
color
<<
"Testing id generation…"
<<
reset
<<
std
::
endl
;
const
std
::
string
first_uuid
=
XmppComponent
::
next_id
();
const
std
::
string
second_uuid
=
XmppComponent
::
next_id
();
std
::
cout
<<
first_uuid
<<
std
::
endl
;
std
::
cout
<<
second_uuid
<<
std
::
endl
;
assert
(
first_uuid
.
size
()
==
36
);
assert
(
second_uuid
.
size
()
==
36
);
assert
(
first_uuid
!=
second_uuid
);
/**
* Utils
...
...
src/xmpp/xmpp_component.cpp
View file @
a63faf6f
...
...
@@ -13,14 +13,14 @@
#include <config.h>
#include <uuid.h>
#ifdef SYSTEMDDAEMON_FOUND
# include <systemd/sd-daemon.h>
#endif
using
namespace
std
::
string_literals
;
unsigned
long
XmppComponent
::
current_id
=
0
;
static
std
::
set
<
std
::
string
>
kickable_errors
{
"gone"
,
"internal-server-error"
,
...
...
@@ -934,5 +934,9 @@ void XmppComponent::send_iq_version_request(const std::string& from,
std
::
string
XmppComponent
::
next_id
()
{
return
std
::
to_string
(
XmppComponent
::
current_id
++
);
char
uuid_str
[
37
];
uuid_t
uuid
;
uuid_generate
(
uuid
);
uuid_unparse
(
uuid
,
uuid_str
);
return
uuid_str
;
}
src/xmpp/xmpp_component.hpp
View file @
a63faf6f
...
...
@@ -235,8 +235,6 @@ private:
*/
std
::
unordered_map
<
std
::
string
,
std
::
unique_ptr
<
Bridge
>>
bridges
;
static
unsigned
long
current_id
;
AdhocCommandsHandler
adhoc_commands_handler
;
XmppComponent
(
const
XmppComponent
&
)
=
delete
;
XmppComponent
(
XmppComponent
&&
)
=
delete
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment