Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
BC
public
liblinphone
Commits
54de6bb6
Commit
54de6bb6
authored
Oct 03, 2017
by
Sylvain Berfini
🎩
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved from shared_ptr<Content> to Content in ChatMessage
parent
5eca36e0
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
55 additions
and
58 deletions
+55
-58
src/chat/chat-message-p.h
src/chat/chat-message-p.h
+2
-2
src/chat/chat-message.cpp
src/chat/chat-message.cpp
+15
-24
src/chat/chat-message.h
src/chat/chat-message.h
+3
-3
src/chat/chat-room.cpp
src/chat/chat-room.cpp
+15
-15
src/chat/modifier/cpim-chat-message-modifier.cpp
src/chat/modifier/cpim-chat-message-modifier.cpp
+14
-14
src/content/content.cpp
src/content/content.cpp
+5
-0
src/content/content.h
src/content/content.h
+1
-0
No files found.
src/chat/chat-message-p.h
View file @
54de6bb6
...
...
@@ -117,8 +117,8 @@ private:
std
::
string
rttMessage
=
""
;
bool
isSecured
=
false
;
bool
isReadOnly
=
false
;
std
::
list
<
std
::
shared_ptr
<
Content
>
>
contents
;
std
::
shared_ptr
<
Content
>
internalContent
;
std
::
list
<
Content
>
contents
;
Content
internalContent
;
std
::
unordered_map
<
std
::
string
,
std
::
string
>
customHeaders
;
std
::
shared_ptr
<
EventsDb
>
eventsDb
;
mutable
LinphoneErrorInfo
*
errorInfo
=
NULL
;
...
...
src/chat/chat-message.cpp
View file @
54de6bb6
...
...
@@ -140,41 +140,35 @@ string ChatMessagePrivate::getSalCustomHeaderValue(const string& name) {
// -----------------------------------------------------------------------------
const
string
&
ChatMessagePrivate
::
getContentType
()
{
if
(
internalContent
)
{
cContentType
=
internalContent
->
getContentType
().
asString
();
if
(
!
internalContent
.
isEmpty
()
)
{
cContentType
=
internalContent
.
getContentType
().
asString
();
}
else
{
if
(
contents
.
size
()
>
0
)
{
shared_ptr
<
Content
>
content
=
contents
.
front
();
cContentType
=
content
->
getContentType
().
asString
();
Content
content
=
contents
.
front
();
cContentType
=
content
.
getContentType
().
asString
();
}
}
return
cContentType
;
}
void
ChatMessagePrivate
::
setContentType
(
const
string
&
contentType
)
{
if
(
!
internalContent
)
{
internalContent
=
make_shared
<
Content
>
();
}
internalContent
->
setContentType
(
contentType
);
internalContent
.
setContentType
(
contentType
);
}
const
string
&
ChatMessagePrivate
::
getText
()
{
if
(
internalContent
)
{
cText
=
internalContent
->
getBodyAsString
();
if
(
!
internalContent
.
isEmpty
()
)
{
cText
=
internalContent
.
getBodyAsString
();
}
else
{
if
(
contents
.
size
()
>
0
)
{
shared_ptr
<
Content
>
content
=
contents
.
front
();
cText
=
content
->
getBodyAsString
();
Content
content
=
contents
.
front
();
cText
=
content
.
getBodyAsString
();
}
}
return
cText
;
}
void
ChatMessagePrivate
::
setText
(
const
string
&
text
)
{
if
(
!
internalContent
)
{
internalContent
=
make_shared
<
Content
>
();
}
internalContent
->
setBody
(
text
);
internalContent
.
setBody
(
text
);
}
LinphoneContent
*
ChatMessagePrivate
::
getFileTransferInformation
()
const
{
...
...
@@ -1297,26 +1291,23 @@ bool ChatMessage::isReadOnly () const {
return
d
->
isReadOnly
;
}
list
<
shared_ptr
<
const
Content
>
>
ChatMessage
::
getContents
()
const
{
const
list
<
Content
>
&
ChatMessage
::
getContents
()
const
{
L_D
();
list
<
shared_ptr
<
const
Content
>
>
contents
;
for
(
const
auto
&
content
:
d
->
contents
)
contents
.
push_back
(
content
);
return
contents
;
return
d
->
contents
;
}
void
ChatMessage
::
addContent
(
const
shared_ptr
<
Content
>
&
content
)
{
void
ChatMessage
::
addContent
(
const
Content
&
content
)
{
L_D
();
if
(
d
->
isReadOnly
)
return
;
d
->
contents
.
push_back
(
content
);
}
void
ChatMessage
::
removeContent
(
const
shared_ptr
<
const
Content
>
&
content
)
{
void
ChatMessage
::
removeContent
(
const
Content
&
content
)
{
L_D
();
if
(
d
->
isReadOnly
)
return
;
d
->
contents
.
remove
(
con
st_pointer_cast
<
Content
>
(
content
)
);
d
->
contents
.
remove
(
con
tent
);
}
string
ChatMessage
::
getCustomHeaderValue
(
const
string
&
headerName
)
const
{
...
...
src/chat/chat-message.h
View file @
54de6bb6
...
...
@@ -133,9 +133,9 @@ public:
bool
isReadOnly
()
const
;
std
::
list
<
std
::
shared_ptr
<
const
Content
>
>
getContents
()
const
;
void
addContent
(
const
std
::
shared_ptr
<
Content
>
&
content
);
void
removeContent
(
const
std
::
shared_ptr
<
const
Content
>
&
content
);
const
std
::
list
<
Content
>
&
getContents
()
const
;
void
addContent
(
const
Content
&
content
);
void
removeContent
(
const
Content
&
content
);
std
::
string
getCustomHeaderValue
(
const
std
::
string
&
headerName
)
const
;
void
addCustomHeader
(
const
std
::
string
&
headerName
,
const
std
::
string
&
headerValue
);
...
...
src/chat/chat-room.cpp
View file @
54de6bb6
...
...
@@ -120,9 +120,9 @@ void ChatRoomPrivate::sendImdn (const string &payload, LinphoneReason reason) {
msg
->
setFromAddress
(
identity
);
msg
->
setToAddress
(
peerAddress
.
asString
());
shared_ptr
<
Content
>
content
=
make_shared
<
Content
>
()
;
content
->
setContentType
(
"message/imdn+xml"
);
content
->
setBody
(
payload
);
Content
content
;
content
.
setContentType
(
"message/imdn+xml"
);
content
.
setBody
(
payload
);
msg
->
addContent
(
content
);
/* Do not try to encrypt the notification when it is reporting an error (maybe it should be bypassed only for some reasons). */
...
...
@@ -212,9 +212,9 @@ void ChatRoomPrivate::sendIsComposingNotification () {
msg
->
setFromAddress
(
identity
);
msg
->
setToAddress
(
peerAddress
.
asString
());
shared_ptr
<
Content
>
content
=
make_shared
<
Content
>
()
;
content
->
setContentType
(
"application/im-iscomposing+xml"
);
content
->
setBody
(
payload
);
Content
content
;
content
.
setContentType
(
"application/im-iscomposing+xml"
);
content
.
setBody
(
payload
);
msg
->
addContent
(
content
);
LinphoneImEncryptionEngine
*
imee
=
linphone_core_get_im_encryption_engine
(
core
);
...
...
@@ -269,14 +269,14 @@ int ChatRoomPrivate::createChatMessageFromDb (int argc, char **argv, char **colN
if
(
!
message
)
{
message
=
q
->
createMessage
();
shared_ptr
<
Content
>
content
=
make_shared
<
Content
>
()
;
Content
content
;
message
->
addContent
(
content
);
if
(
argv
[
4
])
{
content
->
setBody
(
argv
[
4
]);
content
.
setBody
(
argv
[
4
]);
}
if
(
argv
[
13
])
{
content
->
setContentType
(
argv
[
13
]);
content
.
setContentType
(
argv
[
13
]);
}
Address
peer
(
peerAddress
.
asString
());
...
...
@@ -399,9 +399,9 @@ LinphoneReason ChatRoomPrivate::messageReceived (SalOp *op, const SalMessage *sa
msg
=
q
->
createMessage
();
shared_ptr
<
Content
>
content
=
make_shared
<
Content
>
()
;
content
->
setContentType
(
salMsg
->
content_type
);
content
->
setBody
(
salMsg
->
text
?
salMsg
->
text
:
""
);
Content
content
;
content
.
setContentType
(
salMsg
->
content_type
);
content
.
setBody
(
salMsg
->
text
?
salMsg
->
text
:
""
);
msg
->
addContent
(
content
);
msg
->
setToAddress
(
op
->
get_to
()
?
op
->
get_to
()
:
linphone_core_get_identity
(
core
));
...
...
@@ -565,9 +565,9 @@ shared_ptr<ChatMessage> ChatRoom::createMessage (const string &message) {
L_D
();
shared_ptr
<
ChatMessage
>
chatMessage
=
createMessage
();
shared_ptr
<
Content
>
content
=
make_shared
<
Content
>
()
;
content
->
setContentType
(
"text/plain"
);
content
->
setBody
(
message
);
Content
content
;
content
.
setContentType
(
"text/plain"
);
content
.
setBody
(
message
);
chatMessage
->
addContent
(
content
);
chatMessage
->
setToAddress
(
d
->
peerAddress
);
...
...
src/chat/modifier/cpim-chat-message-modifier.cpp
View file @
54de6bb6
...
...
@@ -37,8 +37,8 @@ int CpimChatMessageModifier::encode (ChatMessagePrivate *messagePrivate) {
cpimContentTypeHeader
.
setValue
(
"Message/CPIM"
);
message
.
addCpimHeader
(
cpimContentTypeHeader
);
shared_ptr
<
Content
>
content
;
if
(
messagePrivate
->
internalContent
)
{
Content
content
;
if
(
!
messagePrivate
->
internalContent
.
isEmpty
()
)
{
// Another ChatMessageModifier was called before this one, we apply our changes on the private content
content
=
messagePrivate
->
internalContent
;
}
else
{
...
...
@@ -48,8 +48,8 @@ int CpimChatMessageModifier::encode (ChatMessagePrivate *messagePrivate) {
content
=
messagePrivate
->
contents
.
front
();
}
string
contentType
=
content
->
getContentType
().
asString
();
const
vector
<
char
>
body
=
content
->
getBody
();
string
contentType
=
content
.
getContentType
().
asString
();
const
vector
<
char
>
body
=
content
.
getBody
();
string
contentBody
(
body
.
begin
(),
body
.
end
());
Cpim
::
GenericHeader
contentTypeHeader
;
...
...
@@ -62,33 +62,33 @@ int CpimChatMessageModifier::encode (ChatMessagePrivate *messagePrivate) {
if
(
!
message
.
isValid
())
{
//TODO
}
else
{
shared_ptr
<
Content
>
newContent
=
make_shared
<
Content
>
()
;
Content
newContent
;
ContentType
newContentType
(
"Message/CPIM"
);
newContent
->
setContentType
(
newContentType
);
newContent
->
setBody
(
message
.
asString
());
newContent
.
setContentType
(
newContentType
);
newContent
.
setBody
(
message
.
asString
());
messagePrivate
->
internalContent
=
newContent
;
}
return
0
;
}
int
CpimChatMessageModifier
::
decode
(
ChatMessagePrivate
*
messagePrivate
)
{
shared_ptr
<
Content
>
content
;
if
(
messagePrivate
->
internalContent
)
{
Content
content
;
if
(
!
messagePrivate
->
internalContent
.
isEmpty
()
)
{
content
=
messagePrivate
->
internalContent
;
}
else
{
content
=
messagePrivate
->
contents
.
front
();
}
ContentType
contentType
=
content
->
getContentType
();
ContentType
contentType
=
content
.
getContentType
();
if
(
contentType
.
asString
()
==
"Message/CPIM"
)
{
const
vector
<
char
>
body
=
content
->
getBody
();
const
vector
<
char
>
body
=
content
.
getBody
();
string
contentBody
(
body
.
begin
(),
body
.
end
());
shared_ptr
<
const
Cpim
::
Message
>
message
=
Cpim
::
Message
::
createFromString
(
contentBody
);
if
(
message
&&
message
->
isValid
())
{
shared_ptr
<
Content
>
newContent
=
make_shared
<
Content
>
()
;
Content
newContent
;
ContentType
newContentType
(
message
->
getContentHeaders
()
->
front
()
->
getValue
());
newContent
->
setContentType
(
newContentType
);
newContent
->
setBody
(
message
->
getContent
());
newContent
.
setContentType
(
newContentType
);
newContent
.
setBody
(
message
->
getContent
());
}
else
{
//TODO
}
...
...
src/content/content.cpp
View file @
54de6bb6
...
...
@@ -67,6 +67,11 @@ Content &Content::operator= (Content &&src) {
return
*
this
;
}
bool
Content
::
operator
==
(
const
Content
&
content
)
{
// return true if the two are equal, and false otherwise.
return
true
;
}
const
ContentType
&
Content
::
getContentType
()
const
{
L_D
();
return
d
->
contentType
;
...
...
src/content/content.h
View file @
54de6bb6
...
...
@@ -38,6 +38,7 @@ public:
Content
&
operator
=
(
const
Content
&
src
);
Content
&
operator
=
(
Content
&&
src
);
bool
operator
==
(
const
Content
&
content
);
const
ContentType
&
getContentType
()
const
;
void
setContentType
(
const
ContentType
&
contentType
);
...
...
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