Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
J
jami-daemon
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
131
Issues
131
List
Boards
Labels
Service Desk
Milestones
Iterations
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Analytics
Analytics
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
savoirfairelinux
jami-daemon
Commits
7f215008
Unverified
Commit
7f215008
authored
Aug 24, 2020
by
Aline Gondim Santos
Committed by
Sébastien Blin
Aug 31, 2020
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
plugin: add editable preference
Change-Id: I61c074464e21344b2d7a1d64023f23bd96139c3b
parent
b424a5d0
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
230 additions
and
12 deletions
+230
-12
bin/dbus/cx.ring.Ring.PluginManagerInterface.xml
bin/dbus/cx.ring.Ring.PluginManagerInterface.xml
+11
-0
bin/dbus/dbuspluginmanagerinterface.cpp
bin/dbus/dbuspluginmanagerinterface.cpp
+8
-0
bin/dbus/dbuspluginmanagerinterface.h
bin/dbus/dbuspluginmanagerinterface.h
+3
-0
bin/jni/plugin_manager_interface.i
bin/jni/plugin_manager_interface.i
+3
-0
configure.ac
configure.ac
+1
-1
meson.build
meson.build
+1
-1
src/client/plugin_manager_interface.cpp
src/client/plugin_manager_interface.cpp
+10
-0
src/dring/plugin_manager_interface.h
src/dring/plugin_manager_interface.h
+3
-0
src/fileutils.cpp
src/fileutils.cpp
+30
-0
src/fileutils.h
src/fileutils.h
+4
-0
src/plugin/jamipluginmanager.cpp
src/plugin/jamipluginmanager.cpp
+131
-8
src/plugin/jamipluginmanager.h
src/plugin/jamipluginmanager.h
+23
-0
src/plugin/mediahandler.h
src/plugin/mediahandler.h
+2
-2
No files found.
bin/dbus/cx.ring.Ring.PluginManagerInterface.xml
View file @
7f215008
...
...
@@ -154,5 +154,16 @@
</arg>
</method>
<method
name=
"addValueToPreference"
tp:name-for-bindings=
"addValueToPreference"
>
<tp:added
version=
"9.6.0"
/>
<arg
type=
"s"
name=
"pluginId"
direction=
"in"
>
</arg>
<arg
type=
"s"
name=
"preferenceKey"
direction=
"in"
>
</arg>
<arg
type=
"s"
name=
"value"
direction=
"in"
>
</arg>
<arg
type=
"b"
name=
"status"
direction=
"out"
>
</arg>
</method>
</interface>
</node>
bin/dbus/dbuspluginmanagerinterface.cpp
View file @
7f215008
...
...
@@ -132,3 +132,11 @@ DBusPluginManagerInterface::getCallMediaHandlerStatus()
{
return
DRing
::
getCallMediaHandlerStatus
();
}
bool
DBusPluginManagerInterface
::
addValueToPreference
(
const
std
::
string
&
pluginId
,
const
std
::
string
&
preferenceKey
,
const
std
::
string
&
value
)
{
return
DRing
::
addValueToPreference
(
pluginId
,
preferenceKey
,
value
);
}
bin/dbus/dbuspluginmanagerinterface.h
View file @
7f215008
...
...
@@ -71,4 +71,7 @@ class DRING_PUBLIC DBusPluginManagerInterface :
bool
getPluginsEnabled
();
void
setPluginsEnabled
(
const
bool
&
state
);
std
::
map
<
std
::
string
,
std
::
string
>
getCallMediaHandlerStatus
();
bool
addValueToPreference
(
const
std
::
string
&
pluginId
,
const
std
::
string
&
preferenceKey
,
const
std
::
string
&
value
);
};
bin/jni/plugin_manager_interface.i
View file @
7f215008
...
...
@@ -42,4 +42,7 @@ std::map<std::string,std::string> getCallMediaHandlerDetails(const std::string&
bool
getPluginsEnabled
()
;
void
setPluginsEnabled
(
bool
state
)
;
std
::
map
<
std
::
string
,
std
::
string
>
getCallMediaHandlerStatus
()
;
bool
addValueToPreference
(
const
std
::
string&
pluginId
,
const
std
::
string&
preferenceKey
,
const
std
::
string&
value
)
;
}
configure.ac
View file @
7f215008
...
...
@@ -2,7 +2,7 @@ dnl Jami - configure.ac for automake 1.9 and autoconf 2.59
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ([2.65])
AC_INIT([Jami Daemon],[9.
5
.0],[ring@gnu.org],[jami])
AC_INIT([Jami Daemon],[9.
6
.0],[ring@gnu.org],[jami])
AC_COPYRIGHT([[Copyright (c) Savoir-faire Linux 2004-2020]])
AC_REVISION([$Revision$])
...
...
meson.build
View file @
7f215008
project('jami-daemon', ['c', 'cpp'],
version: '9.
5
.0',
version: '9.
6
.0',
license: 'GPL3+',
default_options: ['cpp_std=gnu++17', 'buildtype=debugoptimized'],
meson_version:'>= 0.54'
...
...
src/client/plugin_manager_interface.cpp
View file @
7f215008
...
...
@@ -144,4 +144,14 @@ getCallMediaHandlerStatus()
.
getCallServicesManager
()
.
getCallMediaHandlerStatus
();
}
bool
addValueToPreference
(
const
std
::
string
&
pluginId
,
const
std
::
string
&
preferenceKey
,
const
std
::
string
&
value
)
{
return
jami
::
Manager
::
instance
().
getJamiPluginManager
().
addValueToPreference
(
pluginId
,
preferenceKey
,
value
);
}
}
// namespace DRing
src/dring/plugin_manager_interface.h
View file @
7f215008
...
...
@@ -53,4 +53,7 @@ DRING_PUBLIC std::map<std::string,std::string> getCallMediaHandlerDetails(const
DRING_PUBLIC
bool
getPluginsEnabled
();
DRING_PUBLIC
void
setPluginsEnabled
(
bool
state
);
DRING_PUBLIC
std
::
map
<
std
::
string
,
std
::
string
>
getCallMediaHandlerStatus
();
DRING_PUBLIC
bool
addValueToPreference
(
const
std
::
string
&
pluginId
,
const
std
::
string
&
preferenceKey
,
const
std
::
string
&
value
);
}
src/fileutils.cpp
View file @
7f215008
...
...
@@ -1023,5 +1023,35 @@ accessFile(const std::string& file, int mode)
#endif
}
std
::
string
getFileName
(
const
std
::
string
&
filePath
)
{
std
::
string
fileName
=
filePath
;
const
size_t
last_slash_idx
=
fileName
.
find_last_of
(
DIR_SEPARATOR_STR_ESC
);
if
(
std
::
string
::
npos
!=
last_slash_idx
)
{
fileName
.
erase
(
0
,
last_slash_idx
+
1
);
}
return
fileName
;
}
std
::
string
removeExtension
(
const
std
::
string
&
filePath
)
{
std
::
string
fileName
=
filePath
;
const
size_t
period_idx
=
fileName
.
rfind
(
'.'
);
if
(
std
::
string
::
npos
!=
period_idx
)
{
fileName
.
erase
(
period_idx
);
}
return
fileName
;
}
std
::
string
getExtension
(
const
std
::
string
&
filePath
)
{
std
::
string
fileExt
=
filePath
;
fileExt
=
fileExt
.
substr
(
fileExt
.
find_last_of
(
'.'
));
return
fileExt
;
}
}
// namespace jami
}
// namespace fileutils
src/fileutils.h
View file @
7f215008
...
...
@@ -176,6 +176,10 @@ std::string md5sum(const std::vector<uint8_t>& buffer);
*/
int
accessFile
(
const
std
::
string
&
file
,
int
mode
);
std
::
string
getFileName
(
const
std
::
string
&
filePath
);
std
::
string
removeExtension
(
const
std
::
string
&
filePath
);
std
::
string
getExtension
(
const
std
::
string
&
filePath
);
}
// namespace fileutils
}
// namespace jami
...
...
src/plugin/jamipluginmanager.cpp
View file @
7f215008
...
...
@@ -34,6 +34,7 @@ extern "C" {
#include <archive.h>
}
#include "fileutils.h"
#include <json/json.h>
#include <msgpack.hpp>
...
...
@@ -337,11 +338,10 @@ JamiPluginManager::unloadPlugin(const std::string& rootPath)
void
JamiPluginManager
::
togglePlugin
(
const
std
::
string
&
rootPath
,
bool
toggle
)
{
//This function should not be used as is
//One should modify it to perform plugin install followed by load
//rootPath should be the jplpath!
try
{
// This function should not be used as is
// One should modify it to perform plugin install followed by load
// rootPath should be the jplpath!
try
{
std
::
string
soPath
=
getPluginDetails
(
rootPath
).
at
(
"soPath"
);
// remove the previous plugin object if it was registered
pm_
.
destroyPluginComponents
(
soPath
);
...
...
@@ -372,6 +372,8 @@ std::vector<std::map<std::string, std::string>>
JamiPluginManager
::
getPluginPreferences
(
const
std
::
string
&
rootPath
)
{
const
std
::
string
preferenceFilePath
=
getPreferencesConfigFilePath
(
rootPath
);
std
::
map
<
std
::
string
,
std
::
map
<
std
::
string
,
std
::
string
>>
userPreferences
=
getUserPreferencesValuesMap
(
rootPath
);
std
::
ifstream
file
(
preferenceFilePath
);
Json
::
Value
root
;
Json
::
CharReaderBuilder
rbuilder
;
...
...
@@ -389,11 +391,34 @@ JamiPluginManager::getPluginPreferences(const std::string& rootPath)
std
::
string
key
=
jsonPreference
.
get
(
"key"
,
"None"
).
asString
();
if
(
type
!=
"None"
&&
key
!=
"None"
)
{
if
(
keys
.
find
(
key
)
==
keys
.
end
())
{
const
auto
&
preferenceAttributes
=
parsePreferenceConfig
(
jsonPreference
,
type
);
std
::
map
<
std
::
string
,
std
::
string
>
preferenceAttributes
=
parsePreferenceConfig
(
jsonPreference
,
type
);
// If the parsing of the attributes was successful, commit the map and the key
if
(
!
preferenceAttributes
.
empty
())
{
preferences
.
push_back
(
std
::
move
(
preferenceAttributes
));
if
(
!
userPreferences
[
key
].
empty
())
{
preferenceAttributes
[
"entryValues"
]
=
userPreferences
[
key
][
"entryValues"
];
preferenceAttributes
[
"entries"
]
=
userPreferences
[
key
][
"entries"
];
}
preferenceAttributes
[
"entryValues"
]
=
std
::
regex_replace
(
preferenceAttributes
[
"entryValues"
],
std
::
regex
(
"
\\
["
),
"$2"
);
preferenceAttributes
[
"entryValues"
]
=
std
::
regex_replace
(
preferenceAttributes
[
"entryValues"
],
std
::
regex
(
"
\\
]"
),
"$2"
);
preferenceAttributes
[
"entries"
]
=
std
::
regex_replace
(
preferenceAttributes
[
"entries"
],
std
::
regex
(
"
\\
["
),
"$2"
);
preferenceAttributes
[
"entries"
]
=
std
::
regex_replace
(
preferenceAttributes
[
"entries"
],
std
::
regex
(
"
\\
]"
),
"$2"
);
preferences
.
emplace_back
(
std
::
move
(
preferenceAttributes
));
keys
.
insert
(
key
);
}
}
...
...
@@ -443,6 +468,41 @@ JamiPluginManager::getPluginUserPreferencesValuesMap(const std::string& rootPath
return
rmap
;
}
std
::
map
<
std
::
string
,
std
::
map
<
std
::
string
,
std
::
string
>>
JamiPluginManager
::
getUserPreferencesValuesMap
(
const
std
::
string
&
rootPath
)
{
const
std
::
string
preferencesValuesFilePath
=
pluginAddedPreferencesValuesFilePath
(
rootPath
);
std
::
ifstream
file
(
preferencesValuesFilePath
,
std
::
ios
::
binary
);
std
::
map
<
std
::
string
,
std
::
map
<
std
::
string
,
std
::
string
>>
rmap
;
// If file is accessible
if
(
file
.
good
())
{
std
::
lock_guard
<
std
::
mutex
>
guard
(
fileutils
::
getFileLock
(
preferencesValuesFilePath
));
// Get file size
std
::
string
str
;
file
.
seekg
(
0
,
std
::
ios
::
end
);
size_t
fileSize
=
static_cast
<
size_t
>
(
file
.
tellg
());
// If not empty
if
(
fileSize
>
0
)
{
// Read whole file content and put it in the string str
str
.
reserve
(
static_cast
<
size_t
>
(
file
.
tellg
()));
file
.
seekg
(
0
,
std
::
ios
::
beg
);
str
.
assign
((
std
::
istreambuf_iterator
<
char
>
(
file
)),
std
::
istreambuf_iterator
<
char
>
());
file
.
close
();
try
{
// Unpack the string
msgpack
::
object_handle
oh
=
msgpack
::
unpack
(
str
.
data
(),
str
.
size
());
// Deserialized object is valid during the msgpack::object_handle instance is alive.
msgpack
::
object
deserialized
=
oh
.
get
();
deserialized
.
convert
(
rmap
);
}
catch
(
const
std
::
exception
&
e
)
{
JAMI_ERR
()
<<
e
.
what
();
}
}
}
return
rmap
;
}
bool
JamiPluginManager
::
setPluginPreference
(
const
std
::
string
&
rootPath
,
const
std
::
string
&
key
,
...
...
@@ -521,6 +581,69 @@ JamiPluginManager::resetPluginPreferencesValuesMap(const std::string& rootPath)
return
returnValue
;
}
bool
JamiPluginManager
::
copyFileToPluginData
(
const
std
::
string
&
pluginId
,
const
std
::
string
&
value
,
const
std
::
string
&
preferenceCategory
,
std
::
string
&
fileName
,
std
::
string
&
fileExt
)
{
if
(
!
fileutils
::
isFile
(
value
))
return
false
;
const
std
::
string
destinationDir
{
pluginId
+
DIR_SEPARATOR_CH
+
"data"
+
DIR_SEPARATOR_CH
+
preferenceCategory
+
DIR_SEPARATOR_CH
};
fileName
=
fileutils
::
removeExtension
(
fileutils
::
getFileName
(
value
));
fileExt
=
fileutils
::
getExtension
(
value
);
auto
srcData
=
fileutils
::
loadFile
(
value
);
if
(
fileutils
::
isFile
(
destinationDir
+
fileName
+
fileExt
))
{
fileutils
::
saveFile
(
destinationDir
+
fileName
+
fileExt
,
srcData
);
return
false
;
}
fileutils
::
saveFile
(
destinationDir
+
fileName
+
fileExt
,
srcData
);
return
true
;
}
bool
JamiPluginManager
::
addValueToPreference
(
const
std
::
string
&
pluginId
,
const
std
::
string
&
preferenceKey
,
const
std
::
string
&
value
)
{
std
::
map
<
std
::
string
,
std
::
map
<
std
::
string
,
std
::
string
>>
userPreferences
=
getUserPreferencesValuesMap
(
pluginId
);
std
::
vector
<
std
::
map
<
std
::
string
,
std
::
string
>>
preferences
=
getPluginPreferences
(
pluginId
);
for
(
auto
&
preference
:
preferences
)
{
if
(
preference
[
"key"
]
==
preferenceKey
)
{
std
::
string
fileName
,
fileExt
;
if
(
!
copyFileToPluginData
(
pluginId
,
value
,
preference
[
"category"
],
fileName
,
fileExt
))
{
return
setPluginPreference
(
pluginId
,
preferenceKey
,
fileName
+
fileExt
);
}
setPluginPreference
(
pluginId
,
preferenceKey
,
fileName
+
fileExt
);
userPreferences
[
preferenceKey
][
"entries"
]
=
preference
[
"entries"
]
+
","
+
fileName
;
userPreferences
[
preferenceKey
][
"entryValues"
]
=
preference
[
"entryValues"
]
+
","
+
fileName
+
fileExt
;
const
std
::
string
preferencesValuesFilePath
=
pluginAddedPreferencesValuesFilePath
(
pluginId
);
std
::
ofstream
fs
(
preferencesValuesFilePath
,
std
::
ios
::
binary
);
if
(
!
fs
.
good
())
{
return
false
;
}
try
{
std
::
lock_guard
<
std
::
mutex
>
guard
(
fileutils
::
getFileLock
(
preferencesValuesFilePath
));
msgpack
::
pack
(
fs
,
userPreferences
);
return
true
;
}
catch
(
const
std
::
exception
&
e
)
{
JAMI_ERR
()
<<
e
.
what
();
return
false
;
}
}
}
}
std
::
map
<
std
::
string
,
std
::
string
>
JamiPluginManager
::
readPluginManifestFromArchive
(
const
std
::
string
&
jplPath
)
{
...
...
src/plugin/jamipluginmanager.h
View file @
7f215008
...
...
@@ -125,6 +125,10 @@ public:
bool
resetPluginPreferencesValuesMap
(
const
std
::
string
&
rootPath
);
bool
addValueToPreference
(
const
std
::
string
&
pluginId
,
const
std
::
string
&
preferenceKey
,
const
std
::
string
&
value
);
public:
CallServicesManager
&
getCallServicesManager
()
{
return
csm_
;
}
...
...
@@ -180,6 +184,13 @@ private:
}
std
::
map
<
std
::
string
,
std
::
string
>
getPluginUserPreferencesValuesMap
(
const
std
::
string
&
rootPath
);
std
::
map
<
std
::
string
,
std
::
map
<
std
::
string
,
std
::
string
>>
getUserPreferencesValuesMap
(
const
std
::
string
&
rootPath
);
bool
copyFileToPluginData
(
const
std
::
string
&
pluginId
,
const
std
::
string
&
value
,
const
std
::
string
&
preferenceCategory
,
std
::
string
&
fileName
,
std
::
string
&
fileExt
);
/**
* @brief getPreferencesConfigFilePath
...
...
@@ -205,6 +216,18 @@ private:
return
rootPath
+
DIR_SEPARATOR_CH
+
"preferences.msgpack"
;
}
/**
* @brief pluginAddedPreferencesValuesFilePath
* Returns the plugin added preferences values file path from the plugin root path
* This is entirely defined by how the plugin files are structured
* @param plugin rootPath
* @return path of the preferences values
*/
std
::
string
pluginAddedPreferencesValuesFilePath
(
const
std
::
string
&
rootPath
)
const
{
return
rootPath
+
DIR_SEPARATOR_CH
+
"addedPreferences.msgpack"
;
}
void
registerServices
();
private:
...
...
src/plugin/mediahandler.h
View file @
7f215008
...
...
@@ -40,8 +40,8 @@ public:
* The id is the path of the plugin that created this MediaHandler
* @return
*/
std
::
string
id
()
const
{
return
id_
;}
virtual
void
setId
(
const
std
::
string
&
id
)
final
{
id_
=
id
;
}
std
::
string
id
()
const
{
return
id_
;
}
virtual
void
setId
(
const
std
::
string
&
id
)
final
{
id_
=
id
;
}
private:
std
::
string
id_
;
...
...
Adrien Béraud
@aberaud
mentioned in commit
69d60a49
·
Sep 01, 2020
mentioned in commit
69d60a49
mentioned in commit 69d60a49408aa5ffefa6492fafd43766168d53d3
Toggle commit list
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