Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
portabledsb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
External Wiki
External Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
App_Technologies
portabledsb
Commits
d660d1d6
Commit
d660d1d6
authored
Jan 04, 2016
by
jacobgladish
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added better version of Guid (needs tested)
parent
629c1550
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
88 additions
and
26 deletions
+88
-26
Bridge/AllJoynAbout.cpp
Bridge/AllJoynAbout.cpp
+2
-2
Common/Guid.cpp
Common/Guid.cpp
+74
-0
Common/Guid.h
Common/Guid.h
+11
-24
Makefile
Makefile
+1
-0
No files found.
Bridge/AllJoynAbout.cpp
View file @
d660d1d6
...
...
@@ -3,7 +3,7 @@
namespace
{
common
::
Guid
const
kDefaultAppGuid
=
common
::
Guid
::
FromString
(
"DA9C7763-C3E0-4B3B-B190-5BEF8DF96E4D"
);
common
::
Guid
const
kDefaultAppGuid
=
common
::
Guid
::
Parse
(
"DA9C7763-C3E0-4B3B-B190-5BEF8DF96E4D"
);
char
const
*
kDefaultLanguageForAbout
=
"en"
;
char
const
*
kUnknownAdapter
=
"Unknown Device"
;
char
const
*
kUnknownManufacturer
=
"Unknown"
;
...
...
@@ -108,7 +108,7 @@ AllJoynAbout::ReadDeviceId(std::string&)
QStatus
AllJoynAbout
::
CreateAndSaveDeviceId
(
std
::
string
&
deviceId
)
{
common
::
Guid
guid
=
common
::
Guid
::
Create
();
common
::
Guid
guid
=
common
::
Guid
::
NewGuid
();
deviceId
=
guid
.
ToString
();
// TODO: need to persist this configuration
...
...
Common/Guid.cpp
0 → 100644
View file @
d660d1d6
#include <Common/Guid.h>
#include <string.h>
common
::
Guid
::
Guid
()
{
memset
(
m_uuid
,
0
,
sizeof
(
uuid_t
));
}
common
::
Guid
::
Guid
(
uuid_t
id
)
{
memcpy
(
m_uuid
,
id
,
sizeof
(
uuid_t
));
}
common
::
Guid
common
::
Guid
::
NewGuid
()
{
#ifdef __linux__
char
id
[
17
];
memset
(
id
,
0
,
sizeof
(
id
));
#else
uuid_string_t
id
;
#endif
uuid_t
uuid
;
uuid_generate_random
(
uuid
);
return
Guid
(
uuid
);
}
common
::
Guid
common
::
Guid
::
Parse
(
char
const
*
s
)
{
if
(
s
==
NULL
)
return
Guid
::
Null
();
uuid_t
id
;
if
(
uuid_parse
(
s
,
id
)
==
0
)
return
Guid
(
id
);
else
return
Guid
::
Null
();
}
common
::
Guid
const
&
common
::
Guid
::
Null
()
{
static
Guid
zeroGuid
=
Guid
();
return
zeroGuid
;
}
std
::
string
common
::
Guid
::
ToString
()
const
{
char
buff
[
64
];
memset
(
buff
,
0
,
sizeof
(
buff
));
uuid_unparse_lower
(
m_uuid
,
buff
);
return
std
::
string
(
buff
);
}
bool
common
::
Guid
::
operator
<
(
Guid
const
&
rhs
)
const
{
return
uuid_compare
(
m_uuid
,
rhs
.
m_uuid
)
<
0
;
}
bool
common
::
Guid
::
operator
==
(
Guid
const
&
rhs
)
const
{
return
uuid_compare
(
m_uuid
,
rhs
.
m_uuid
)
==
0
;
}
bool
common
::
Guid
::
operator
!=
(
Guid
const
&
rhs
)
const
{
return
uuid_compare
(
m_uuid
,
rhs
.
m_uuid
)
!=
0
;
}
Common/Guid.h
View file @
d660d1d6
#pragma once
#include <string>
#include <uuid/uuid.h>
#include <string>
namespace
common
{
class
Guid
{
public:
static
Guid
Create
()
{
uuid_t
uuid
;
uuid_generate_random
(
uuid
);
#ifdef __linux__
char
s
[
37
];
#else
uuid_string_t
s
;
#endif
static
Guid
const
&
Null
();
uuid_unparse
(
uuid
,
s
);
static
Guid
NewGuid
();
static
Guid
Parse
(
char
const
*
s
);
return
Guid
(
std
::
string
(
s
));
}
std
::
string
ToString
()
const
;
static
Guid
FromString
(
char
const
*
s
)
{
return
Guid
(
s
);
}
std
::
string
ToString
()
const
{
return
m_uuid
;
}
bool
operator
<
(
Guid
const
&
rhs
)
const
;
bool
operator
==
(
Guid
const
&
rhs
)
const
;
bool
operator
!=
(
Guid
const
&
rhs
)
const
;
private:
Guid
(
std
::
string
const
&
uuid
)
:
m_uuid
(
uuid
)
{
}
Guid
();
Guid
(
uuid_t
id
);
private:
std
::
string
m_uuid
;
uuid_t
m_uuid
;
};
}
Makefile
View file @
d660d1d6
...
...
@@ -12,6 +12,7 @@ SRCS=DeviceProviders/AllJoynProvider.cpp \
Bridge/DeviceSignal.cpp
\
Common/Log.cpp
\
Common/Variant.cpp
\
Common/Guid.cpp
\
Adapters/MockAdapter/MockAdapter.cpp
\
Adapters/MockAdapter/MockDevices.cpp
\
Adapters/MockAdapter/MockAdapterDevice.cpp
\
...
...
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