Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
savoirfairelinux
jami-daemon
Commits
319bde2a
Commit
319bde2a
authored
Mar 23, 2012
by
Tristan Matthews
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
HookPreference: cleanup
parent
0fe52b0a
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
113 additions
and
35 deletions
+113
-35
daemon/src/preferences.cpp
daemon/src/preferences.cpp
+6
-2
daemon/src/preferences.h
daemon/src/preferences.h
+3
-4
daemon/src/sip/Makefile.am
daemon/src/sip/Makefile.am
+3
-1
daemon/src/sip/sip_utils.cpp
daemon/src/sip/sip_utils.cpp
+53
-0
daemon/src/sip/sip_utils.h
daemon/src/sip/sip_utils.h
+47
-0
daemon/src/sip/sipvoiplink.cpp
daemon/src/sip/sipvoiplink.cpp
+1
-28
No files found.
daemon/src/preferences.cpp
View file @
319bde2a
...
...
@@ -34,6 +34,7 @@
#include "config/yamlemitter.h"
#include "config/yamlnode.h"
#include "hooks/urlhook.h"
#include "sip/sip_utils.h"
#include <sstream>
#include "global.h"
#include <cassert>
...
...
@@ -275,9 +276,12 @@ void HookPreference::unserialize(const Conf::MappingNode *map)
map
->
getValue
(
urlSipFieldKey
,
&
urlSipField_
);
}
void
HookPreference
::
run
(
const
std
::
string
&
header
)
void
HookPreference
::
run
Hook
(
pjsip_msg
*
msg
)
{
UrlHook
::
runAction
(
urlCommand_
,
header
);
if
(
sipEnabled_
)
{
std
::
string
header
(
sip_utils
::
fetchHeaderValue
(
msg
,
urlSipField_
));
UrlHook
::
runAction
(
urlCommand_
,
header
);
}
}
AudioPreference
::
AudioPreference
()
:
...
...
daemon/src/preferences.h
View file @
319bde2a
...
...
@@ -328,10 +328,11 @@ class AddressbookPreference : public Serializable {
bool
business_
;
bool
home_
;
bool
mobile_
;
};
class
pjsip_msg
;
class
HookPreference
:
public
Serializable
{
public:
HookPreference
();
...
...
@@ -349,9 +350,7 @@ class HookPreference : public Serializable {
}
std
::
map
<
std
::
string
,
std
::
string
>
toMap
()
const
;
bool
getSipEnabled
()
const
{
return
sipEnabled_
;
}
std
::
string
getUrlSipField
()
const
{
return
urlSipField_
;
}
void
run
(
const
std
::
string
&
header
);
void
runHook
(
pjsip_msg
*
msg
);
private:
bool
iax2Enabled_
;
...
...
daemon/src/sip/Makefile.am
View file @
319bde2a
...
...
@@ -14,7 +14,9 @@ libsiplink_la_SOURCES = \
sdp.h
\
sipaccount.h
\
sipcall.h
\
sipvoiplink.h
sipvoiplink.h
\
sip_utils.cpp
\
sip_utils.h
libsiplink_la_CXXFLAGS
=
\
@PCRE_LIBS@
daemon/src/sip/sip_utils.cpp
0 → 100644
View file @
319bde2a
/*
* Copyright (C) 2004-2012 Savoir-Faire Linux Inc.
*
* Author: Tristan Matthews <tristan.matthews@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* Additional permission under GNU GPL version 3 section 7:
*
* If you modify this program, or any covered work, by linking or
* combining it with the OpenSSL project's OpenSSL library (or a
* modified version of that library), containing parts covered by the
* terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
* grants you additional permission to convey the resulting work.
* Corresponding Source for a non-source form of such a combination
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
#include "sip_utils.h"
#include "pj/string.h"
#include "pjsip/sip_msg.h"
std
::
string
sip_utils
::
fetchHeaderValue
(
pjsip_msg
*
msg
,
const
std
::
string
&
field
)
{
pj_str_t
name
=
pj_str
((
char
*
)
field
.
c_str
());
pjsip_generic_string_hdr
*
hdr
=
static_cast
<
pjsip_generic_string_hdr
*>
(
pjsip_msg_find_hdr_by_name
(
msg
,
&
name
,
NULL
));
if
(
!
hdr
)
return
""
;
std
::
string
value
(
hdr
->
hvalue
.
ptr
,
hdr
->
hvalue
.
slen
);
size_t
pos
=
value
.
find
(
"
\n
"
);
if
(
pos
!=
std
::
string
::
npos
)
return
value
.
substr
(
0
,
pos
);
else
return
""
;
}
daemon/src/sip/sip_utils.h
0 → 100644
View file @
319bde2a
/*
* Copyright (C) 2004-2012 Savoir-Faire Linux Inc.
*
* Author: Tristan Matthews <tristan.matthews@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* Additional permission under GNU GPL version 3 section 7:
*
* If you modify this program, or any covered work, by linking or
* combining it with the OpenSSL project's OpenSSL library (or a
* modified version of that library), containing parts covered by the
* terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
* grants you additional permission to convey the resulting work.
* Corresponding Source for a non-source form of such a combination
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
#ifndef SIP_UTILS_H_
#define SIP_UTILS_H_
#include <string>
class
pjsip_msg
;
namespace
sip_utils
{
/**
* Helper function to parser header from incoming sip messages
* @return Header from SIP message
*/
std
::
string
fetchHeaderValue
(
pjsip_msg
*
msg
,
const
std
::
string
&
field
);
}
#endif // SIP_UTILS_H_
daemon/src/sip/sipvoiplink.cpp
View file @
319bde2a
...
...
@@ -89,11 +89,6 @@ static std::map<std::string, std::string> transferCallID;
*/
void
setCallMediaLocal
(
SIPCall
*
call
,
const
std
::
string
&
localIP
);
/**
* Helper function to parser header from incoming sip messages
*/
std
::
string
fetchHeaderValue
(
pjsip_msg
*
msg
,
const
std
::
string
&
field
);
static
pj_caching_pool
pool_cache
,
*
cp_
=
&
pool_cache
;
static
pj_pool_t
*
pool_
;
static
pjsip_endpoint
*
endpt_
;
...
...
@@ -306,10 +301,7 @@ pj_bool_t transaction_request_cb(pjsip_rx_data *rdata)
return
true
;
}
if
(
Manager
::
instance
().
hookPreference
.
getSipEnabled
())
{
std
::
string
header_value
(
fetchHeaderValue
(
rdata
->
msg_info
.
msg
,
Manager
::
instance
().
hookPreference
.
getUrlSipField
()));
Manager
::
instance
().
hookPreference
.
run
(
header_value
);
}
Manager
::
instance
().
hookPreference
.
runHook
(
rdata
->
msg_info
.
msg
);
SIPCall
*
call
=
new
SIPCall
(
Manager
::
instance
().
getNewCallID
(),
Call
::
INCOMING
,
cp_
);
Manager
::
instance
().
associateCallToAccount
(
call
->
getCallId
(),
account_id
);
...
...
@@ -2113,25 +2105,6 @@ void setCallMediaLocal(SIPCall* call, const std::string &localIP)
call
->
setLocalAudioPort
(
callLocalAudioPort
);
call
->
getLocalSDP
()
->
setLocalPublishedAudioPort
(
callLocalExternAudioPort
);
}
std
::
string
fetchHeaderValue
(
pjsip_msg
*
msg
,
const
std
::
string
&
field
)
{
pj_str_t
name
=
pj_str
((
char
*
)
field
.
c_str
());
pjsip_generic_string_hdr
*
hdr
=
static_cast
<
pjsip_generic_string_hdr
*>
(
pjsip_msg_find_hdr_by_name
(
msg
,
&
name
,
NULL
));
if
(
!
hdr
)
return
""
;
std
::
string
value
(
hdr
->
hvalue
.
ptr
,
hdr
->
hvalue
.
slen
);
size_t
pos
=
value
.
find
(
"
\n
"
);
if
(
pos
!=
std
::
string
::
npos
)
return
value
.
substr
(
0
,
pos
);
else
return
""
;
}
}
// end anonymous namespace
std
::
vector
<
std
::
string
>
SIPVoIPLink
::
getAllIpInterfaceByName
()
...
...
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