Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
BC
public
liblinphone
Commits
ffc4abad
Commit
ffc4abad
authored
Sep 19, 2017
by
Ronan
Browse files
fix(chat): coding style
parent
ad7cb274
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
73 additions
and
70 deletions
+73
-70
src/chat/chat-message-p.h
src/chat/chat-message-p.h
+3
-2
src/chat/modifier/cpim-chat-message-modifier.cpp
src/chat/modifier/cpim-chat-message-modifier.cpp
+70
-68
No files found.
src/chat/chat-message-p.h
View file @
ffc4abad
...
...
@@ -28,6 +28,9 @@
LINPHONE_BEGIN_NAMESPACE
class
ChatMessagePrivate
:
public
ObjectPrivate
{
friend
class
CpimChatMessageModifier
;
friend
class
MultipartChatMessageModifier
;
private:
std
::
weak_ptr
<
ChatRoom
>
chatRoom
;
ChatMessage
::
Direction
direction
=
ChatMessage
::
Incoming
;
...
...
@@ -47,8 +50,6 @@ private:
std
::
shared_ptr
<
EventsDb
>
eventsDb
;
L_DECLARE_PUBLIC
(
ChatMessage
);
friend
class
CpimChatMessageModifier
;
friend
class
MultipartChatMessageModifier
;
};
LINPHONE_END_NAMESPACE
...
...
src/chat/modifier/cpim-chat-message-modifier.cpp
View file @
ffc4abad
...
...
@@ -16,83 +16,85 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <vector>
#include <vector>
#include "c
ontent/content-type
.h"
#include "c
ontent/content
.h"
#include "c
hat/chat-message-p
.h"
#include "c
hat/cpim/cpim
.h"
#include "c
hat/chat-message-p
.h"
#include "c
hat/cpim/cpim
.h"
#include "c
ontent/content-type
.h"
#include "c
ontent/content
.h"
#include "cpim-chat-message-modifier.h"
#include "cpim-chat-message-modifier.h"
LINPHONE_BEGIN_NAMESPACE
using
namespace
std
;
// =============================================================================
void
CpimChatMessageModifier
::
encode
(
LinphonePrivate
::
ChatMessagePrivate
*
msg
)
{
Cpim
::
Message
message
;
Cpim
::
GenericHeader
cpimContentTypeHeader
;
using
namespace
std
;
LINPHONE_BEGIN_NAMESPACE
void
CpimChatMessageModifier
::
encode
(
LinphonePrivate
::
ChatMessagePrivate
*
msg
)
{
Cpim
::
Message
message
;
Cpim
::
GenericHeader
cpimContentTypeHeader
;
cpimContentTypeHeader
.
setName
(
"Content-Type"
);
cpimContentTypeHeader
.
setValue
(
"Message/CPIM"
);
message
.
addCpimHeader
(
cpimContentTypeHeader
);
shared_ptr
<
Content
>
content
;
if
(
msg
->
internalContent
)
{
// Another ChatMessageModifier was called before this one, we apply our changes on the private content
content
=
msg
->
internalContent
;
}
else
{
// We're the first ChatMessageModifier to be called, we'll create the private content from the public one
// We take the first one because if there is more of them, the multipart modifier should have been called first
// So we should not be in this block
content
=
msg
->
contents
.
front
();
}
cpimContentTypeHeader
.
setValue
(
"Message/CPIM"
);
message
.
addCpimHeader
(
cpimContentTypeHeader
);
string
contentType
=
content
->
getContentType
().
asString
();
const
vector
<
char
>
body
=
content
->
getBody
();
string
contentBody
(
body
.
begin
(),
body
.
end
());
shared_ptr
<
Content
>
content
;
if
(
msg
->
internalContent
)
{
// Another ChatMessageModifier was called before this one, we apply our changes on the private content
content
=
msg
->
internalContent
;
}
else
{
// We're the first ChatMessageModifier to be called, we'll create the private content from the public one
// We take the first one because if there is more of them, the multipart modifier should have been called first
// So we should not be in this block
content
=
msg
->
contents
.
front
();
}
Cpim
::
GenericHeader
contentTypeHeader
;
string
contentType
=
content
->
getContentType
().
asString
();
const
vector
<
char
>
body
=
content
->
getBody
();
string
contentBody
(
body
.
begin
(),
body
.
end
());
Cpim
::
GenericHeader
contentTypeHeader
;
contentTypeHeader
.
setName
(
"Content-Type"
);
contentTypeHeader
.
setValue
(
contentType
);
message
.
addContentHeader
(
contentTypeHeader
);
contentTypeHeader
.
setValue
(
contentType
);
message
.
addContentHeader
(
contentTypeHeader
);
message
.
setContent
(
contentBody
);
message
.
setContent
(
contentBody
);
if
(
!
message
.
isValid
())
{
//TODO
}
else
{
shared_ptr
<
Content
>
newContent
=
make_shared
<
Content
>
();
ContentType
newContentType
(
"Message/CPIM"
);
newContent
->
setContentType
(
newContentType
);
newContent
->
setBody
(
message
.
asString
());
msg
->
internalContent
=
newContent
;
}
}
if
(
!
message
.
isValid
())
{
//TODO
}
else
{
shared_ptr
<
Content
>
newContent
=
make_shared
<
Content
>
();
ContentType
newContentType
(
"Message/CPIM"
);
newContent
->
setContentType
(
newContentType
);
newContent
->
setBody
(
message
.
asString
());
msg
->
internalContent
=
newContent
;
}
}
void
CpimChatMessageModifier
::
decode
(
LinphonePrivate
::
ChatMessagePrivate
*
msg
)
{
shared_ptr
<
Content
>
content
;
if
(
msg
->
internalContent
)
{
content
=
msg
->
internalContent
;
}
else
{
content
=
msg
->
contents
.
front
();
}
void
CpimChatMessageModifier
::
decode
(
LinphonePrivate
::
ChatMessagePrivate
*
msg
)
{
shared_ptr
<
Content
>
content
;
if
(
msg
->
internalContent
)
{
content
=
msg
->
internalContent
;
}
else
{
content
=
msg
->
contents
.
front
();
}
ContentType
contentType
=
content
->
getContentType
();
if
(
contentType
.
asString
()
==
"Message/CPIM"
)
{
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
>
();
ContentType
newContentType
(
message
->
getContentHeaders
()
->
front
()
->
getValue
());
newContent
->
setContentType
(
newContentType
);
newContent
->
setBody
(
message
->
getContent
());
}
else
{
//TODO
}
}
else
{
//TODO
}
}
ContentType
contentType
=
content
->
getContentType
();
if
(
contentType
.
asString
()
==
"Message/CPIM"
)
{
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
>
();
ContentType
newContentType
(
message
->
getContentHeaders
()
->
front
()
->
getValue
());
newContent
->
setContentType
(
newContentType
);
newContent
->
setBody
(
message
->
getContent
());
}
else
{
//TODO
}
}
else
{
//TODO
}
}
LINPHONE_END_NAMESPACE
\ No newline at end of file
LINPHONE_END_NAMESPACE
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