Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
linphone-desktop
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
linphone-desktop
Commits
86cfc1c8
Commit
86cfc1c8
authored
Sep 06, 2017
by
nicolas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(Cli): method syntax auto generated when --cli-help
parent
0721a22b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
65 deletions
+41
-65
en.ts
assets/languages/en.ts
+5
-25
fr.ts
assets/languages/fr.ts
+4
-24
Cli.cpp
src/app/cli/Cli.cpp
+31
-10
Cli.hpp
src/app/cli/Cli.hpp
+1
-6
No files found.
assets/languages/en.ts
View file @
86cfc1c8
...
...
@@ -431,43 +431,23 @@ Server url not configured.</translation>
<
/message
>
<
message
>
<
source
>
showFunctionDescription
<
/source
>
<
translation
>
Shows
the
main
window
of
the
application
.
<
/translation
>
<
/message
>
<
message
>
<
source
>
showCliDescription
<
/source
>
<
translation
>&
quot
;
show
&
quot
;
<
/translation
>
<
translation
>
Show
the
main
window
of
the
application
.
<
/translation
>
<
/message
>
<
message
>
<
source
>
callFunctionDescription
<
/source
>
<
translation
>
Initiates
a
call
towards
&
lt
;
sip
-
address
&
gt
;.
<
/translation
>
<
/message
>
<
message
>
<
source
>
callCliDescription
<
/source
>
<
translation
>&
quot
;
call
sip
-
address
=&
lt
;
sip
-
address
&
gt
;
&
quot
;
<
/translation
>
<
translation
>
Initiate
a
call
to
the
sip
-
address
.
<
/translation
>
<
/message
>
<
message
>
<
source
>
initiateConferenceFunctionDescription
<
/source
>
<
translation
>
Initiates
a
conference
of
id
&
lt
;
id
&
gt
;.
<
/translation
>
<
/message
>
<
message
>
<
source
>
initiateConferenceCliDescription
<
/source
>
<
translation
>&
quot
;
initiate
-
conference
sip
-
address
=&
lt
;
my
sip
-
address
&
gt
;
conference
-
id
=&
lt
;
id
&
gt
;
&
quot
;
<
/translation
>
<
translation
>
Initiate
a
conference
.
<
/translation
>
<
/message
>
<
message
>
<
source
>
joinConferenceFunctionDescription
<
/source
>
<
translation
>
Joins
the
n
°
&
lt
;
id
&
gt
;
conference
hosted
by
the
&
lt
;
host
sip
-
address
&
gt
;
as
&
lt
;
name
&
gt
;.
If
you
are
connected
to
a
proxy
config
,
see
join
-
conference
-
as
.
<
/translation
>
<
/message
>
<
message
>
<
source
>
joinConferenceCliDescription
<
/source
>
<
translation
>&
quot
;
join
-
conference
sip
-
address
=&
lt
;
host
sip
-
address
&
gt
;
conference
-
id
=&
lt
;
id
&
gt
;
display
-
name
=&
lt
;
name
&
gt
;
&
quot
;
<
/translation
>
<
translation
>
Join
the
conference
hosted
by
the
sip
-
address
as
display
-
name
.
If
you
are
connected
to
a
proxy
config
,
see
join
-
conference
-
as
.
<
/translation
>
<
/message
>
<
message
>
<
source
>
joinConferenceAsFunctionDescription
<
/source
>
<
translation
>
Joins
the
n
°
&
lt
;
id
&
gt
;
conference
hosted
by
the
&
lt
;
host
sip
-
address
&
gt
;
as
&
lt
;
my
sip
-
address
&
gt
;.
If
you
are
not
connected
to
a
proxy
-
config
,
see
join
-
conference
.
<
/translation
>
<
/message
>
<
message
>
<
source
>
joinConferenceAsCliDescription
<
/source
>
<
translation
>&
quot
;
join
-
conference
-
as
sip
-
address
=&
lt
;
host
sip
-
address
&
gt
;
conference
-
id
=&
lt
;
id
&
gt
;
guest
-
sip
-
address
=&
lt
;
my
sip
-
address
&
gt
;
&
quot
;
<
/translation
>
<
translation
>
Join
the
conference
hosted
by
the
sip
-
address
as
with
the
guest
-
sip
-
address
.
If
you
are
not
connected
to
a
proxy
-
config
,
see
join
-
conference
.
<
/translation
>
<
/message
>
<
/context
>
<
context
>
...
...
assets/languages/fr.ts
View file @
86cfc1c8
...
...
@@ -433,41 +433,21 @@ Url du serveur non configurée.</translation>
<
source
>
showFunctionDescription
<
/source
>
<
translation
>
Affiche
la
fen
ê
tre
principale
de
l
&
apos
;
application
.
<
/translation
>
<
/message
>
<
message
>
<
source
>
showCliDescription
<
/source
>
<
translation
>&
quot
;
show
&
quot
;
<
/translation
>
<
/message
>
<
message
>
<
source
>
callFunctionDescription
<
/source
>
<
translation
>
Initie
un
appel
vers
&
lt
;
sip
-
address
&
gt
;.
<
/translation
>
<
/message
>
<
message
>
<
source
>
callCliDescription
<
/source
>
<
translation
>&
quot
;
call
sip
-
address
=&
lt
;
sip
-
address
&
gt
;
&
quot
;
<
/translation
>
<
translation
>
Initie
un
appel
vers
la
sip
-
address
.
<
/translation
>
<
/message
>
<
message
>
<
source
>
initiateConferenceFunctionDescription
<
/source
>
<
translation
>
Initie
une
conf
é
rence
d
&
apos
;
id
&
lt
;
id
&
gt
;.
<
/translation
>
<
/message
>
<
message
>
<
source
>
initiateConferenceCliDescription
<
/source
>
<
translation
>&
quot
;
initiate
-
conference
sip
-
address
=&
lt
;
ma
sip
-
address
&
gt
;
conference
-
id
=&
lt
;
id
&
gt
;
&
quot
;
<
/translation
>
<
translation
>
Initie
une
conf
é
rence
.
<
/translation
>
<
/message
>
<
message
>
<
source
>
joinConferenceFunctionDescription
<
/source
>
<
translation
>
Rejoint
la
conf
é
rence
n
°
&
lt
;
id
&
gt
;
h
é
berg
é
e
par
la
&
lt
;
sip
-
address
de
l
&
apos
;
host
&
gt
;
en
tant
que
&
lt
;
nom
&
gt
;.
Si
vous
ê
tes
connect
é
à
une
proxy
config
,
voir
join
-
conference
-
as
.
<
/translation
>
<
/message
>
<
message
>
<
source
>
joinConferenceCliDescription
<
/source
>
<
translation
>&
quot
;
join
-
conference
sip
-
address
=&
lt
;
sip
-
address
de
l
&
apos
;
host
&
gt
;
conference
-
id
=&
lt
;
id
&
gt
;
display
-
name
=&
lt
;
nom
&
gt
;
&
quot
;
<
/translation
>
<
translation
>
Rejoint
la
conf
é
rence
h
é
berg
é
e
par
la
sip
-
address
avec
un
display
-
name
.
Si
vous
ê
tes
connect
é
à
une
proxy
config
,
voir
join
-
conference
-
as
.
<
/translation
>
<
/message
>
<
message
>
<
source
>
joinConferenceAsFunctionDescription
<
/source
>
<
translation
>
Rejoint
la
conf
é
rence
n
°
&
lt
;
id
&
gt
;
h
é
berg
é
e
par
la
&
lt
;
sip
-
address
de
l
&
apos
;
host
&
gt
;
en
tant
que
&
lt
;
ma
sip
-
address
&
gt
;.
Si
vous
n
&
apos
;
ê
tes
pas
connect
é
à
une
proxy
-
config
,
voir
join
-
conference
.
<
/translation
>
<
/message
>
<
message
>
<
source
>
joinConferenceAsCliDescription
<
/source
>
<
translation
>&
quot
;
join
-
conference
-
as
sip
-
address
=&
lt
;
sip
-
address
de
l
&
apos
;
host
&
gt
;
conference
-
id
=&
lt
;
id
&
gt
;
guest
-
sip
-
address
=&
lt
;
ma
sip
-
address
&
gt
;
&
quot
;
<
/translation
>
<
translation
>
Rejoint
la
conf
é
rence
h
é
berg
é
e
par
la
sip
-
address
avec
la
guest
-
sip
-
address
.
Si
vous
n
&
apos
;
ê
tes
pas
connect
é
à
une
proxy
-
config
,
voir
join
-
conference
.
<
/translation
>
<
/message
>
<
/context
>
<
context
>
...
...
src/app/cli/Cli.cpp
View file @
86cfc1c8
...
...
@@ -219,13 +219,11 @@ static string multilineIndent (const QString &str, int indentationNumber = 0) {
Cli
::
Command
::
Command
(
const
QString
&
functionName
,
const
char
*
functionDescription
,
const
char
*
cliDescription
,
Cli
::
Function
function
,
const
QHash
<
QString
,
Cli
::
Argument
>
&
argsScheme
)
:
mFunctionName
(
functionName
),
mFunctionDescription
(
functionDescription
),
mCliDescription
(
cliDescription
),
mFunction
(
function
),
mArgsScheme
(
argsScheme
)
{}
...
...
@@ -275,6 +273,30 @@ void Cli::Command::executeUri (const shared_ptr<linphone::Address> &address) con
execute
(
args
);
}
QString
Cli
::
Command
::
getFunctionSyntax
()
const
{
QString
functionSyntax
;
functionSyntax
+=
QStringLiteral
(
"
\"
"
);
functionSyntax
+=
mFunctionName
;
for
(
auto
&
argName
:
mArgsScheme
.
keys
()){
functionSyntax
+=
QStringLiteral
(
" "
);
functionSyntax
+=
mArgsScheme
[
argName
].
isOptional
?
QStringLiteral
(
"["
)
:
QStringLiteral
(
""
);
functionSyntax
+=
argName
;
functionSyntax
+=
QStringLiteral
(
"=<"
);
switch
(
mArgsScheme
[
argName
].
type
)
{
case
STRING
:
functionSyntax
+=
QStringLiteral
(
"str"
);
break
;
default:
functionSyntax
+=
QStringLiteral
(
"value"
);
break
;
}
functionSyntax
+=
QString
(
">"
);
functionSyntax
+=
mArgsScheme
[
argName
].
isOptional
?
QStringLiteral
(
"]"
)
:
QStringLiteral
(
""
);
}
functionSyntax
+=
QStringLiteral
(
"
\"
"
);
return
functionSyntax
;
}
// =============================================================================
// FIXME: Do not accept args without value like: cmd toto.
...
...
@@ -283,17 +305,17 @@ QRegExp Cli::mRegExpArgs("(?:(?:([\\w-]+)\\s*)=\\s*(?:\"([^\"\\\\]*(?:\\\\.[^\"\
QRegExp
Cli
::
mRegExpFunctionName
(
"^
\\
s*([a-z-]+)
\\
s*"
);
QMap
<
QString
,
Cli
::
Command
>
Cli
::
mCommands
=
{
createCommand
(
"show"
,
QT_TR_NOOP
(
"showFunctionDescription"
),
QT_TR_NOOP
(
"showCliDescription"
),
::
cliShow
),
createCommand
(
"call"
,
QT_TR_NOOP
(
"callFunctionDescription"
),
QT_TR_NOOP
(
"callCliDescription"
),
::
cliCall
,
{
createCommand
(
"show"
,
QT_TR_NOOP
(
"showFunctionDescription"
),
::
cliShow
),
createCommand
(
"call"
,
QT_TR_NOOP
(
"callFunctionDescription"
),
::
cliCall
,
{
{
"sip-address"
,
{}
}
}),
createCommand
(
"initiate-conference"
,
QT_TR_NOOP
(
"initiateConferenceFunctionDescription"
),
QT_TR_NOOP
(
"initiateConferenceCliDescription"
),
::
cliInitiateConference
,
{
createCommand
(
"initiate-conference"
,
QT_TR_NOOP
(
"initiateConferenceFunctionDescription"
),
::
cliInitiateConference
,
{
{
"sip-address"
,
{}
},
{
"conference-id"
,
{}
}
}),
createCommand
(
"join-conference"
,
QT_TR_NOOP
(
"joinConferenceFunctionDescription"
),
QT_TR_NOOP
(
"joinConferenceCliDescription"
),
::
cliJoinConference
,
{
createCommand
(
"join-conference"
,
QT_TR_NOOP
(
"joinConferenceFunctionDescription"
),
::
cliJoinConference
,
{
{
"sip-address"
,
{}
},
{
"conference-id"
,
{}
},
{
"display-name"
,
{}
}
}),
createCommand
(
"join-conference-as"
,
QT_TR_NOOP
(
"joinConferenceAsFunctionDescription"
),
QT_TR_NOOP
(
"joinConferenceAsCliDescription"
),
::
cliJoinConferenceAs
,
{
createCommand
(
"join-conference-as"
,
QT_TR_NOOP
(
"joinConferenceAsFunctionDescription"
),
::
cliJoinConferenceAs
,
{
{
"sip-address"
,
{}
},
{
"conference-id"
,
{}
},
{
"guest-sip-address"
,
{}
}
})
};
...
...
@@ -354,7 +376,7 @@ void Cli::showHelp () {
multilineIndent
(
tr
(
"commandsName"
))
<<
endl
;
for
(
const
auto
&
method
:
mCommands
.
keys
())
cout
<<
multilineIndent
(
tr
(
mCommands
[
method
].
getCliDescription
()
),
1
)
<<
cout
<<
multilineIndent
(
mCommands
[
method
].
getFunctionSyntax
(
),
1
)
<<
multilineIndent
(
tr
(
mCommands
[
method
].
getFunctionDescription
()),
2
)
<<
endl
;
}
...
...
@@ -364,11 +386,10 @@ void Cli::showHelp () {
pair
<
QString
,
Cli
::
Command
>
Cli
::
createCommand
(
const
QString
&
functionName
,
const
char
*
functionDescription
,
const
char
*
cliDescription
,
Function
function
,
const
QHash
<
QString
,
Argument
>
&
argsScheme
)
{
return
{
functionName
,
Cli
::
Command
(
functionName
,
functionDescription
,
cliDescription
,
function
,
argsScheme
)
};
return
{
functionName
,
Cli
::
Command
(
functionName
,
functionDescription
,
function
,
argsScheme
)
};
}
// -----------------------------------------------------------------------------
...
...
src/app/cli/Cli.hpp
View file @
86cfc1c8
...
...
@@ -60,7 +60,6 @@ class Cli : public QObject {
Command
(
const
QString
&
functionName
,
const
char
*
functionDescription
,
const
char
*
cliDescription
,
Function
function
,
const
QHash
<
QString
,
Argument
>
&
argsScheme
);
...
...
@@ -72,14 +71,11 @@ class Cli : public QObject {
return
mFunctionDescription
;
}
const
char
*
getCliDescription
()
const
{
return
mCliDescription
;
}
QString
getFunctionSyntax
()
const
;
private:
QString
mFunctionName
;
const
char
*
mFunctionDescription
;
const
char
*
mCliDescription
;
Function
mFunction
=
nullptr
;
QHash
<
QString
,
Argument
>
mArgsScheme
;
};
...
...
@@ -103,7 +99,6 @@ private:
static
std
::
pair
<
QString
,
Command
>
createCommand
(
const
QString
&
functionName
,
const
char
*
functionDescription
,
const
char
*
cliDescription
,
Function
function
,
const
QHash
<
QString
,
Argument
>
&
argsScheme
=
QHash
<
QString
,
Argument
>
()
);
...
...
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