Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
mailutils
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
acef5b6f
...
acef5b6f3dae4a8a584603ad8947227967bf4736
authored
2009-05-26 22:46:46 +0200
by
Wojciech Polak
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Add Secret class to libmu_cpp.
1 parent
1f49d2c9
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
141 additions
and
9 deletions
examples/cpp/url-parse.cc
include/mailutils/cpp/Makefile.am
include/mailutils/cpp/mailutils.h
include/mailutils/cpp/secret.h
include/mailutils/cpp/url.h
libmu_cpp/Makefile.am
libmu_cpp/secret.cc
libmu_cpp/url.cc
examples/cpp/url-parse.cc
View file @
acef5b6
...
...
@@ -45,7 +45,11 @@ main ()
cout
<<
"
\t
scheme <"
<<
url
.
get_scheme
()
<<
">"
<<
endl
;
cout
<<
"
\t
user <"
<<
url
.
get_user
()
<<
">"
<<
endl
;
cout
<<
"
\t
passwd <"
<<
url
.
get_passwd
()
<<
">"
<<
endl
;
Secret
sec
=
url
.
get_secret
();
cout
<<
"
\t
passwd <"
<<
sec
.
password
()
<<
">"
<<
endl
;
sec
.
password_unref
();
cout
<<
"
\t
auth <"
<<
url
.
get_auth
()
<<
">"
<<
endl
;
cout
<<
"
\t
host <"
<<
url
.
get_host
()
<<
">"
<<
endl
;
cout
<<
"
\t
port "
<<
url
.
get_port
()
<<
endl
;
...
...
include/mailutils/cpp/Makefile.am
View file @
acef5b6
...
...
@@ -37,6 +37,7 @@ MU_CXX_INCLUDES = \
mutil.h
\
pop3.h
\
registrar.h
\
secret.h
\
stream.h
\
url.h
...
...
include/mailutils/cpp/mailutils.h
View file @
acef5b6
...
...
@@ -35,6 +35,7 @@
#include <mailutils/cpp/mutil.h>
#include <mailutils/cpp/pop3.h>
#include <mailutils/cpp/registrar.h>
#include <mailutils/cpp/secret.h>
#include <mailutils/cpp/stream.h>
#include <mailutils/cpp/url.h>
...
...
include/mailutils/cpp/secret.h
0 → 100644
View file @
acef5b6
/*
GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2009 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301 USA
*/
#ifndef _MUCPP_SECRET_H
#define _MUCPP_SECRET_H
#include <string>
#include <errno.h>
#include <mailutils/secret.h>
#include <mailutils/cpp/error.h>
namespace
mailutils
{
class
Secret
{
protected
:
mu_secret_t
secret
;
bool
owner
;
public
:
Secret
(
const
std
::
string
&
);
Secret
(
const
char
*
str
,
size_t
len
);
Secret
(
const
mu_secret_t
);
~
Secret
();
std
::
string
password
();
void
password_unref
();
};
}
#endif // not _MUCPP_SECRET_H
include/mailutils/cpp/url.h
View file @
acef5b6
...
...
@@ -27,6 +27,7 @@
#include <errno.h>
#include <mailutils/url.h>
#include <mailutils/cpp/error.h>
#include <mailutils/cpp/secret.h>
namespace
mailutils
{
...
...
@@ -46,11 +47,11 @@ class Url
long
get_port
();
std
::
string
get_scheme
();
std
::
string
get_user
();
std
::
string
get_passwd
();
std
::
string
get_auth
();
std
::
string
get_host
();
std
::
string
get_path
();
std
::
vector
<
std
::
string
>
get_query
();
Secret
&
get_secret
();
std
::
string
to_string
();
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
,
Url
&
);
...
...
libmu_cpp/Makefile.am
View file @
acef5b6
...
...
@@ -42,6 +42,7 @@ libmu_cpp_la_SOURCES = \
mutil.cc
\
pop3.cc
\
registrar.cc
\
secret.cc
\
stream.cc
\
url.cc
...
...
libmu_cpp/secret.cc
0 → 100644
View file @
acef5b6
/*
GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2009 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301 USA
*/
#include <mailutils/cpp/secret.h>
using
namespace
mailutils
;
//
// Secret
//
Secret
::
Secret
(
const
std
::
string
&
str
)
{
int
status
=
mu_secret_create
(
&
secret
,
str
.
c_str
(),
str
.
size
());
if
(
status
)
throw
Exception
(
"Secret::Secret"
,
status
);
this
->
owner
=
true
;
}
Secret
::
Secret
(
const
char
*
str
,
size_t
len
)
{
int
status
=
mu_secret_create
(
&
secret
,
str
,
len
);
if
(
status
)
throw
Exception
(
"Secret::Secret"
,
status
);
this
->
owner
=
true
;
}
Secret
::
Secret
(
const
mu_secret_t
secret
)
{
if
(
secret
==
0
)
throw
Exception
(
"Secret::Secret"
,
EINVAL
);
this
->
secret
=
secret
;
this
->
owner
=
false
;
}
Secret
::
~
Secret
()
{
if
(
this
->
owner
)
mu_secret_destroy
(
&
secret
);
}
std
::
string
Secret
::
password
()
{
return
std
::
string
(
mu_secret_password
(
secret
));
}
void
Secret
::
password_unref
()
{
mu_secret_password_unref
(
secret
);
}
libmu_cpp/url.cc
View file @
acef5b6
...
...
@@ -95,16 +95,16 @@ Url :: get_user ()
return
std
::
string
(
buf
?
buf
:
""
);
}
std
::
string
Url
::
get_
passwd
()
Secret
&
Url
::
get_
secret
()
{
const
char
*
buf
=
NULL
;
int
status
=
mu_url_
sget_passwd
(
url
,
&
buf
);
mu_secret_t
c_secret
;
int
status
=
mu_url_
get_secret
(
url
,
&
c_secret
);
if
(
status
==
MU_ERR_NOENT
)
return
""
;
return
*
new
Secret
(
""
)
;
else
if
(
status
)
throw
Exception
(
"Url::get_
passwd
"
,
status
);
return
std
::
string
(
buf
?
buf
:
""
);
throw
Exception
(
"Url::get_
secret
"
,
status
);
return
*
new
Secret
(
c_secret
);
}
std
::
string
...
...
Please
register
or
sign in
to post a comment