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
68bb508c
Commit
68bb508c
authored
Sep 12, 2017
by
Ronan
Browse files
feat(core): add ContentType class
parent
1e1d0d2f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
176 additions
and
3 deletions
+176
-3
src/CMakeLists.txt
src/CMakeLists.txt
+7
-3
src/content/content-type.cpp
src/content/content-type.cpp
+111
-0
src/content/content-type.h
src/content/content-type.h
+58
-0
No files found.
src/CMakeLists.txt
View file @
68bb508c
...
...
@@ -28,13 +28,13 @@ set(LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES
call/call-listener.h
call/call-p.h
call/call.h
chat/basic-chat-room.h
chat/basic-chat-room-p.h
chat/basic-chat-room.h
chat/chat-message.h
chat/chat-room-p.h
chat/chat-room.h
chat/client-group-chat-room.h
chat/client-group-chat-room-p.h
chat/client-group-chat-room.h
chat/cpim/cpim.h
chat/cpim/header/cpim-core-headers.h
chat/cpim/header/cpim-generic-header.h
...
...
@@ -45,8 +45,8 @@ set(LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES
chat/cpim/parser/cpim-parser.h
chat/imdn.h
chat/is-composing.h
chat/real-time-text-chat-room.h
chat/real-time-text-chat-room-p.h
chat/real-time-text-chat-room.h
conference/conference-listener.h
conference/conference-p.h
conference/conference.h
...
...
@@ -63,6 +63,8 @@ set(LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES
conference/session/call-session.h
conference/session/media-session.h
conference/session/port-config.h
content/content-type.h
content/content.h
content/content.h
core/core.h
db/abstract/abstract-db-p.h
...
...
@@ -117,6 +119,8 @@ set(LINPHONE_CXX_OBJECTS_SOURCE_FILES
conference/remote-conference.cpp
conference/session/call-session.cpp
conference/session/media-session.cpp
content/content-type.cpp
content/content.cpp
content/content.cpp
core/core.cpp
db/abstract/abstract-db.cpp
...
...
src/content/content-type.cpp
0 → 100644
View file @
68bb508c
/*
* content-type.cpp
* Copyright (C) 2017 Belledonne Communications SARL
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#include "content-type.h"
#include "object/clonable-object-p.h"
// =============================================================================
using
namespace
std
;
LINPHONE_BEGIN_NAMESPACE
class
ContentTypePrivate
:
public
ClonableObjectPrivate
{
public:
string
type
;
string
subType
;
};
// -----------------------------------------------------------------------------
ContentType
::
ContentType
(
const
string
&
contentType
)
:
ClonableObject
(
*
new
ContentTypePrivate
)
{
L_D
(
ContentType
);
size_t
pos
=
contentType
.
find
(
'/'
);
if
(
pos
==
string
::
npos
)
return
;
if
(
setType
(
contentType
.
substr
(
0
,
pos
)))
{
if
(
!
setSubType
(
contentType
.
substr
(
pos
+
1
)))
d
->
type
.
clear
();
}
}
ContentType
::
ContentType
(
const
string
&
type
,
const
string
&
subType
)
:
ClonableObject
(
*
new
ContentTypePrivate
)
{
L_D
(
ContentType
);
if
(
setType
(
type
))
{
if
(
!
setSubType
(
subType
))
d
->
type
.
clear
();
}
}
ContentType
::
ContentType
(
const
ContentType
&
src
)
:
ContentType
(
src
.
getType
(),
src
.
getSubType
())
{}
ContentType
&
ContentType
::
operator
=
(
const
ContentType
&
src
)
{
if
(
this
!=
&
src
)
{
setType
(
src
.
getType
());
setSubType
(
src
.
getSubType
());
}
return
*
this
;
}
bool
ContentType
::
operator
==
(
const
ContentType
&
contentType
)
{
return
getType
()
==
contentType
.
getType
()
&&
getSubType
()
==
contentType
.
getSubType
();
}
const
string
&
ContentType
::
getType
()
const
{
L_D
(
const
ContentType
);
return
d
->
type
;
}
bool
ContentType
::
setType
(
const
std
::
string
&
type
)
{
L_D
(
ContentType
);
if
(
type
.
find
(
'/'
)
==
string
::
npos
)
{
d
->
type
=
type
;
return
true
;
}
return
false
;
}
const
string
&
ContentType
::
getSubType
()
const
{
L_D
(
const
ContentType
);
return
d
->
subType
;
}
bool
ContentType
::
setSubType
(
const
std
::
string
&
subType
)
{
L_D
(
ContentType
);
if
(
subType
.
find
(
'/'
)
==
string
::
npos
)
{
d
->
subType
=
subType
;
return
true
;
}
return
false
;
}
bool
ContentType
::
isValid
()
const
{
L_D
(
const
ContentType
);
return
!
d
->
type
.
empty
()
&&
!
d
->
subType
.
empty
();
}
string
ContentType
::
asString
()
const
{
L_D
(
const
ContentType
);
return
isValid
()
?
d
->
type
+
"/"
+
d
->
subType
:
""
;
}
LINPHONE_END_NAMESPACE
src/content/content-type.h
0 → 100644
View file @
68bb508c
/*
* content-type.h
* Copyright (C) 2017 Belledonne Communications SARL
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef _CONTENT_TYPE_H_
#define _CONTENT_TYPE_H_
#include <string>
#include "object/clonable-object.h"
// =============================================================================
LINPHONE_BEGIN_NAMESPACE
class
ContentTypePrivate
;
class
LINPHONE_PUBLIC
ContentType
:
public
ClonableObject
{
public:
ContentType
(
const
std
::
string
&
contentType
=
""
);
ContentType
(
const
std
::
string
&
type
,
const
std
::
string
&
subType
);
ContentType
(
const
ContentType
&
src
);
ContentType
&
operator
=
(
const
ContentType
&
src
);
bool
operator
==
(
const
ContentType
&
contentType
);
bool
isValid
()
const
;
const
std
::
string
&
getType
()
const
;
bool
setType
(
const
std
::
string
&
type
);
const
std
::
string
&
getSubType
()
const
;
bool
setSubType
(
const
std
::
string
&
subType
);
std
::
string
asString
()
const
;
private:
L_DECLARE_PRIVATE
(
ContentType
);
};
LINPHONE_END_NAMESPACE
#endif // ifndef _CONTENT_TYPE_H_
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