r3360 - in trunk: libmcrypto/include/libmcrypto libmcrypto/include/libmcrypto/gnutls libmcrypto/include/libmcrypto/openssl libmcrypto/source libmcrypto/source/gnutls libmcrypto/source/openssl libminisip/source/subsystem_signaling/sip libmutil/source minisip/minisip/gui/gtkgui
mikaelsv at minisip.org
mikaelsv at minisip.org
Thu Aug 9 15:48:47 CEST 2007
Author: mikaelsv
Date: 2007-08-09 15:48:47 +0200 (Thu, 09 Aug 2007)
New Revision: 3360
Modified:
trunk/libmcrypto/include/libmcrypto/cert.h
trunk/libmcrypto/include/libmcrypto/gnutls/cert.h
trunk/libmcrypto/include/libmcrypto/openssl/cert.h
trunk/libmcrypto/source/cert.cxx
trunk/libmcrypto/source/gnutls/cert.cxx
trunk/libmcrypto/source/openssl/cert.cxx
trunk/libminisip/source/subsystem_signaling/sip/SipSoftPhoneConfiguration.cxx
trunk/libmutil/source/Timestamp.cxx
trunk/minisip/minisip/gui/gtkgui/CertificateDialog.cxx
Log:
* BUGFIX: The silly double-definition error on Win32 should now be fixed.
* CHANGE: The CertificateSetItem class now "indexes" the associated certificate
when they are loaded/created. This means that one CertificateSetItem class
(formerly ca_db_item) can *only* represent single certificates and *not* entire
directories of certificates.
This change has been made to enable a future certificate cache.
The behaviour of addFile(filename) and addDirectory(dir) has, consequently, also
changed. Both function now call addCertificate(cert) for each certificate, instead
of adding the certificates to the certificate set by themselves.
This will (probably) cause a slight performance hit when Minisip has to
read the directories instead of GNU TLS/OpenSSL, but this is acceptable by me!
* NAMECHANGE: The "item" and "type" attributes of CertificateSetItem have been
renamed. "type" is now called "importMethod" and "item" is now called
"importParameter". These changes were made to better emphasize that a
CertificateSetItem no longer represents a particular "type of information" (a file
or a directory) but rather a certificate loaded from a particular "resource"
(such as a file or directory).
Modified: trunk/libmcrypto/include/libmcrypto/cert.h
===================================================================
--- trunk/libmcrypto/include/libmcrypto/cert.h 2007-08-09 13:06:49 UTC (rev 3359)
+++ trunk/libmcrypto/include/libmcrypto/cert.h 2007-08-09 13:48:47 UTC (rev 3360)
@@ -37,11 +37,11 @@
#include<libmutil/CacheItem.h>
class Certificate;
-
+#if 0
#define CERT_DB_ITEM_TYPE_OTHER 0
#define CERT_DB_ITEM_TYPE_FILE 1
#define CERT_DB_ITEM_TYPE_DIR 2
-
+#endif
class LIBMCRYPTO_API CertificatePair: public MObject {
public:
CertificatePair();
@@ -53,8 +53,13 @@
class LIBMCRYPTO_API CertificateSetItem: public CacheItem {
public:
- std::string item;
- int type;
+ enum CERTSETITEM_IMPORTMETHOD {
+ IMPORTMETHOD_OTHER = 0,
+ IMPORTMETHOD_FILE = 1,
+ IMPORTMETHOD_DIRECTORY = 2
+ };
+ //std::string item;
+ //int type;
virtual ~CertificateSetItem();
@@ -65,19 +70,31 @@
/*
Getters
*/
- std::string getSubject();
- std::vector<std::string> getSubjectAltNames();
- std::string getSubjectKeyIdentifier();
+ std::string getSubject() const;
+ std::vector<std::string> getSubjectAltNames() const;
+ std::string getSubjectKeyIdentifier() const;
- std::string getIssuer();
- std::vector<std::string> getIssuerAltNames();
- std::string getIssuerKeyIdentifier();
+ std::string getIssuer() const;
+ std::vector<std::string> getIssuerAltNames() const;
+ std::string getIssuerKeyIdentifier() const;
- bool isSelfSigned();
+ bool isSelfSigned() const;
- std::string getCertificateUri();
+ std::string getCertificateUri() const;
MRef<Certificate*> getCertificate();
+ CERTSETITEM_IMPORTMETHOD getImportMethod() const;
+ std::string getImportParameter() const;
+
+ /*
+ Setters
+ */
+ void setCertificate(const MRef<Certificate*> cert);
+ void setCertificateUri(const std::string);
+
+ void setImportMethod(const CERTSETITEM_IMPORTMETHOD type);
+ void setImportParameter(const std::string param);
+
/**
* Loads certificates specified by private variables \c certificateUri or \c certificate.
*/
@@ -101,9 +118,11 @@
void unloadCertificateFromMemory();
bool operator ==(const CertificateSetItem item2){ return (
- item2.item == item &&
- item2.type == type);};
+ item2.getImportMethod() == getImportMethod() &&
+ item2.getImportParameter() == getImportParameter());};
+ void reindexCert();
+
private:
/*
Indexed attributes
@@ -128,7 +147,41 @@
std::string certificateUri;
MRef<Certificate*> certificate;
- void reindexCert();
+ /**
+ * Defines what method was used to load the Certificate in this CertificateSetItem.
+ *
+ * The methods can be described as "stored in file", "stored in directory" or "stored
+ * in memory". The idea behind storing this information is to simplify retrieval of
+ * user settings.
+ *
+ * When the Minisip application loads it automatically creates a certificate set
+ * containing all the client's trusted root certificates. Users can, in the GUI,
+ * specify either single certificate files or entire directories. The problem is that
+ * certificates are loaded one by one (certificates in a directory are not batch-added)
+ * and that when the user settings are to be written back to the user's configuration
+ * file there is no longer possible to determine if a particular certificate was loaded
+ * in a "directory batch" or a "single file".
+ *
+ * Since we still want to keep track of this kind of information, so that the
+ * configuration file can be properly created, we have this work-around that allows us
+ * to store additional information about "which method was used" to load the certificate.
+ */
+ CERTSETITEM_IMPORTMETHOD importMethod;
+
+ /**
+ * The interpretation of this property is dependent on the \c importMethod property.
+ *
+ * If \c importMethod is "file" then \c importParameter is the absolut path to the
+ * certifcate (meaning that it specifies the same file as \c certificateUri, but
+ * using a simpler format).
+ *
+ * If \c importMethod is "directory" then \c importParameters is the directory that
+ * the user has selected.
+ *
+ * If \c importMethod id "memory" then \c importParameter is ignored.
+ */
+ std::string importParameter;
+
};
@@ -138,9 +191,9 @@
static CertificateSet *create();
virtual CertificateSet* clone();
- virtual void addDirectory( std::string dir );
- virtual void addFile( std::string file );
- virtual void addCertificate( MRef<Certificate *> cert );
+ void addDirectory( std::string dir );
+ MRef<CertificateSetItem*> addFile( std::string file );
+ virtual MRef<CertificateSetItem*> addCertificate( MRef<Certificate *> cert );
virtual std::list<MRef<CertificateSetItem*> > &getItems();
virtual MRef<CertificateSetItem*> getNext();
virtual void initIndex();
@@ -152,8 +205,8 @@
protected:
CertificateSet();
virtual void addItem( MRef<CertificateSetItem*> item );
- virtual MRef<CertificateSetItem*> createDirItem( std::string dir );
- virtual MRef<CertificateSetItem*> createFileItem( std::string file );
+ //virtual MRef<CertificateSetItem*> createDirItem( std::string dir );
+ //virtual MRef<CertificateSetItem*> createFileItem( std::string file );
virtual MRef<CertificateSetItem*> createCertItem( MRef<Certificate*> cert );
private:
Modified: trunk/libmcrypto/include/libmcrypto/gnutls/cert.h
===================================================================
--- trunk/libmcrypto/include/libmcrypto/gnutls/cert.h 2007-08-09 13:06:49 UTC (rev 3359)
+++ trunk/libmcrypto/include/libmcrypto/gnutls/cert.h 2007-08-09 13:48:47 UTC (rev 3360)
@@ -83,8 +83,8 @@
virtual std::string getMemObjectType() const {return "GtlsCertificateSet";}
protected:
- MRef<CertificateSetItem*> createDirItem( std::string dir );
- MRef<CertificateSetItem*> createFileItem( std::string file );
+ //MRef<CertificateSetItem*> createDirItem( std::string dir );
+ //MRef<CertificateSetItem*> createFileItem( std::string file );
MRef<CertificateSetItem*> createCertItem( MRef<Certificate*> cert );
private:
Modified: trunk/libmcrypto/include/libmcrypto/openssl/cert.h
===================================================================
--- trunk/libmcrypto/include/libmcrypto/openssl/cert.h 2007-08-09 13:06:49 UTC (rev 3359)
+++ trunk/libmcrypto/include/libmcrypto/openssl/cert.h 2007-08-09 13:48:47 UTC (rev 3360)
@@ -57,9 +57,9 @@
X509_STORE * getDb();
virtual std::string getMemObjectType() const {return "OsslCertificateSet";}
- void addDirectory( std::string dir );
- void addFile( std::string file );
- void addCertificate( MRef<Certificate *> cert );
+ //void addDirectory( std::string dir );
+ //void addFile( std::string file );
+ MRef<CertificateSetItem*> addCertificate( MRef<Certificate *> cert );
private:
X509_STORE * cert_db;
Modified: trunk/libmcrypto/source/cert.cxx
===================================================================
--- trunk/libmcrypto/source/cert.cxx 2007-08-09 13:06:49 UTC (rev 3359)
+++ trunk/libmcrypto/source/cert.cxx 2007-08-09 13:48:47 UTC (rev 3360)
@@ -34,6 +34,8 @@
#include <fstream>
#include <libmnetutil/Downloader.h>
+#include <libmnetutil/FileUrl.h>
+#include <libmutil/FileSystemUtils.h>
using namespace std;
@@ -172,7 +174,12 @@
CertificateSetItem::~CertificateSetItem(){
}
-
+void CertificateSetItem::setCertificate(const MRef<Certificate*> cert) {
+ certificate = cert;
+}
+void CertificateSetItem::setCertificateUri(const std::string uri) {
+ certificateUri = uri;
+}
void CertificateSetItem::loadCertAndIndex() {
if (!certificate.isNull()) {
reindexCert();
@@ -188,31 +195,31 @@
}
}
-std::string CertificateSetItem::getSubject() {
+std::string CertificateSetItem::getSubject() const {
return subject;
}
-std::vector<std::string> CertificateSetItem::getSubjectAltNames() {
+std::vector<std::string> CertificateSetItem::getSubjectAltNames() const {
return subjectAltNames;
}
-std::string CertificateSetItem::getSubjectKeyIdentifier() {
+std::string CertificateSetItem::getSubjectKeyIdentifier() const {
return subjectKeyIdentifier;
}
-std::string CertificateSetItem::getIssuer() {
+std::string CertificateSetItem::getIssuer() const {
return issuer;
}
-std::vector<std::string> CertificateSetItem::getIssuerAltNames() {
+std::vector<std::string> CertificateSetItem::getIssuerAltNames() const {
return issuerAltNames;
}
-std::string CertificateSetItem::getIssuerKeyIdentifier() {
+std::string CertificateSetItem::getIssuerKeyIdentifier() const {
return issuerKeyIdentifier;
}
-bool CertificateSetItem::isSelfSigned() {
+bool CertificateSetItem::isSelfSigned() const {
return selfSigned;
}
-std::string CertificateSetItem::getCertificateUri() {
+std::string CertificateSetItem::getCertificateUri() const {
return certificateUri;
}
MRef<Certificate*> CertificateSetItem::getCertificate() {
@@ -220,10 +227,25 @@
loadCertAndIndex();
return certificate;
}
+void CertificateSetItem::setImportMethod(const CertificateSetItem::CERTSETITEM_IMPORTMETHOD type) {
+ importMethod = type;
+}
+void CertificateSetItem::setImportParameter(const std::string param) {
+ importParameter = param;
+}
+CertificateSetItem::CERTSETITEM_IMPORTMETHOD CertificateSetItem::getImportMethod() const {
+ return importMethod;
+}
+std::string CertificateSetItem::getImportParameter() const {
+ return importParameter;
+}
void CertificateSetItem::reindexCert() {
if (!certificate.isNull()) {
+ std::cerr << "REINDEX CERTIFICATE" << std::endl;
subject = certificate->getName();
+ std::cerr << " " << subject << std::endl;
+
std::vector<std::string> subjectAltNames;
Certificate::SubjectAltName altTypes[] = {Certificate::SAN_DNSNAME, Certificate::SAN_RFC822NAME, Certificate::SAN_URI, Certificate::SAN_IPADDRESS};
@@ -276,11 +298,34 @@
mLock.unlock();
}
+void CertificateSet::addDirectory(std::string dir) {
+ std::list<std::string> certs = FileSystemUtils::directoryContents(dir, false);
+ for (std::list<std::string>::iterator i = certs.begin(); i != certs.end(); i++) {
+ std::cerr << "File: " << *i << std::endl;
+ MRef<CertificateSetItem*> item = addFile(*i);
+ item->setImportMethod(CertificateSetItem::IMPORTMETHOD_DIRECTORY);
+ item->setImportParameter(dir);
+ }
+}
+MRef<CertificateSetItem*> CertificateSet::addFile(std::string file) {
+ try {
+ MRef<Certificate*> cert = Certificate::load(file);
+ MRef<CertificateSetItem*> item = addCertificate(cert);
+ FileUrl uri;
+ uri.setPath(file);
+ item->setCertificateUri(uri.getString());
+ item->setImportMethod(CertificateSetItem::IMPORTMETHOD_FILE);
+ item->setImportParameter(uri.getString());
+ } catch (CertificateException & ex) {
+ }
+}
+
void CertificateSet::addItem( MRef<CertificateSetItem*> item ){
items.push_back( item );
items_index = items.begin();
}
+/*
MRef<CertificateSetItem*> CertificateSet::createDirItem( std::string dir ){
MRef<CertificateSetItem*> item = new CertificateSetItem();
@@ -296,15 +341,18 @@
item->type = CERT_DB_ITEM_TYPE_FILE;
return item;
}
+*/
MRef<CertificateSetItem*> CertificateSet::createCertItem( MRef<Certificate*> cert ){
- MRef<CertificateSetItem*> item = new CertificateSetItem();
+ MRef<CertificateSetItem*> item = new CertificateSetItem(cert);
- item->item = "";
- item->type = CERT_DB_ITEM_TYPE_OTHER;
+ //item->item = "";
+ //item->type = CERT_DB_ITEM_TYPE_OTHER;
+ item->setCertificate(cert);
+ item->reindexCert();
return item;
}
-
+/*
void CertificateSet::addDirectory( string dir ){
MRef<CertificateSetItem*> item = createDirItem( dir );
addItem( item );
@@ -314,10 +362,13 @@
MRef<CertificateSetItem*> item = createFileItem( file );
addItem( item );
}
-
-void CertificateSet::addCertificate( MRef<Certificate *> cert ){
- MRef<CertificateSetItem*> item = createCertItem( cert );
- addItem( item );
+*/
+MRef<CertificateSetItem*> CertificateSet::addCertificate(MRef<Certificate *> cert){
+ MRef<CertificateSetItem*> item = createCertItem(cert);
+ addItem(item);
+ item->setImportMethod(CertificateSetItem::IMPORTMETHOD_OTHER);
+ item->setImportParameter("");
+ return item;
}
void CertificateSet::remove( MRef<CertificateSetItem*> removedItem ){
Modified: trunk/libmcrypto/source/gnutls/cert.cxx
===================================================================
--- trunk/libmcrypto/source/gnutls/cert.cxx 2007-08-09 13:06:49 UTC (rev 3359)
+++ trunk/libmcrypto/source/gnutls/cert.cxx 2007-08-09 13:48:47 UTC (rev 3360)
@@ -1265,7 +1265,7 @@
file = fileName;
}
*/
-
+/*
MRef<CertificateSetItem*> GtlsCertificateSet::createDirItem( std::string dir ){
CertificateSetItem * item = new GtlsCertificateSetItem();
@@ -1320,15 +1320,17 @@
// return NULL;
return item;
}
-
+*/
MRef<CertificateSetItem*> GtlsCertificateSet::createCertItem( MRef<Certificate*> cert ){
GtlsCertificateSetItem * item = new GtlsCertificateSetItem();
- item->item = "";
- item->type = CERT_DB_ITEM_TYPE_OTHER;
+ //item->item = "";
+ //item->type = CERT_DB_ITEM_TYPE_OTHER;
item->num_certs = 1;
item->certs = new gnutls_x509_crt_t[item->num_certs];
item->certs[0] = NULL;
+ item->setCertificate(cert);
+ item->reindexCert();
int ret = gnutls_x509_crt_init( &item->certs[0] );
Modified: trunk/libmcrypto/source/openssl/cert.cxx
===================================================================
--- trunk/libmcrypto/source/openssl/cert.cxx 2007-08-09 13:06:49 UTC (rev 3359)
+++ trunk/libmcrypto/source/openssl/cert.cxx 2007-08-09 13:48:47 UTC (rev 3360)
@@ -728,7 +728,7 @@
X509_STORE * OsslCertificateSet::getDb(){
return cert_db;
}
-
+/*
void OsslCertificateSet::addDirectory( string dir ){
X509_LOOKUP * lookup = NULL;
@@ -760,12 +760,13 @@
CertificateSet::addFile( file );
}
+*/
-void OsslCertificateSet::addCertificate( MRef<Certificate *> cert ){
+MRef<CertificateSetItem*> OsslCertificateSet::addCertificate( MRef<Certificate *> cert ){
OsslCertificate *ssl_cert = (OsslCertificate *)*cert;
X509_STORE_add_cert( cert_db, ssl_cert->getOpensslCertificate() );
- CertificateSet::addCertificate( cert );
+ return CertificateSet::addCertificate( cert );
}
Modified: trunk/libminisip/source/subsystem_signaling/sip/SipSoftPhoneConfiguration.cxx
===================================================================
--- trunk/libminisip/source/subsystem_signaling/sip/SipSoftPhoneConfiguration.cxx 2007-08-09 13:06:49 UTC (rev 3359)
+++ trunk/libminisip/source/subsystem_signaling/sip/SipSoftPhoneConfiguration.cxx 2007-08-09 13:48:47 UTC (rev 3360)
@@ -1,16 +1,16 @@
/*
Copyright (C) 2004-2006 the Minisip Team
-
+
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 2.1 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -25,7 +25,7 @@
* Johan Bilien <jobi at via.ecp.fr>
* Cesc Santasusana < cesc Dot santa at@ gmail dOT com>
* Purpose
- * Read and write from the configuration file.
+ * Read and write from the configuration file.
*
*/
@@ -68,7 +68,7 @@
using namespace std;
-SipSoftPhoneConfiguration::SipSoftPhoneConfiguration():
+SipSoftPhoneConfiguration::SipSoftPhoneConfiguration():
//securityConfig(),
//sip(NULL),
useSTUN(false),
@@ -98,12 +98,12 @@
}
void SipSoftPhoneConfiguration::save(){
- massert(backend); // This will happen if save() is done without first
+ massert(backend); // This will happen if save() is done without first
// having done a load() (bug).
-
- //Set the version of the file ...
+
+ //Set the version of the file ...
backend->save( "version", CONFIG_FILE_VERSION_REQUIRED );
-
+
backend->save( "local_udp_port", sipStackConfig->localUdpPort );
backend->save( "local_tcp_port", sipStackConfig->localTcpPort );
backend->save( "local_tls_port", sipStackConfig->localTlsPort );
@@ -111,7 +111,7 @@
backend->save( "instance_id", sipStackConfig->instanceId);
//securityConfig.save( backend );
-
+
list< MRef<SipIdentity *> >::iterator iIdent;
uint32_t ii = 0;
@@ -120,14 +120,14 @@
for( iIdent = identities.begin(); iIdent != identities.end(); ii++, iIdent ++){
//cerr << "Saving identity: " << (*iIdent)->getDebugString() << endl;
accountPath = string("account[")+itoa(ii)+"]/";
-
+
(*iIdent)->lock();
backend->save( accountPath + "account_name", (*iIdent)->identityIdentifier );
-
+
backend->save( accountPath + "sip_uri", (*iIdent)->getSipUri().getUserIpString() );
-
+
/*From SipDialogSecurity below*/
backend->saveBool(accountPath + "secured", (*iIdent)->securityEnabled);
backend->saveBool(accountPath + "use_zrtp", /*use_zrtp*/ (*iIdent)->use_zrtp);
@@ -212,17 +212,31 @@
MRef<CertificateSetItem*> caDbItem = cert_db->getNext();
+ /*
+ Since each item in caDbItem represents a single certificate it is important
+ to keep track of which certificate directories have been saved, since it is
+ otherwise very likely that the same directory name will be added multiple
+ times (as it is very likely that several of the loaded certificates are
+ stored in the same directory).
+ */
+ std::set<std::string> processedCertDirs;
+
while( !caDbItem.isNull() ){
- switch( caDbItem->type ){
- case CERT_DB_ITEM_TYPE_FILE:
+ switch( caDbItem->getImportMethod() ){
+ case CertificateSetItem::IMPORTMETHOD_FILE:
backend->save(accountPath + "ca_file["+itoa(iFile)+"]",
- caDbItem->item);
- iFile ++;
+ caDbItem->getImportParameter());
+ iFile++;
break;
- case CERT_DB_ITEM_TYPE_DIR:
- backend->save(accountPath + "ca_dir["+itoa(iDir)+"]",
- caDbItem->item);
- iDir ++;
+ case CertificateSetItem::IMPORTMETHOD_DIRECTORY:
+ if (processedCertDirs.find(caDbItem->getImportParameter()) != processedCertDirs.end()) {
+ // The directory that the current certificate belongs to
+ // has not been preivously saved.
+ backend->save(accountPath + "ca_dir["+itoa(iDir)+"]",
+ caDbItem->getImportParameter());
+ processedCertDirs.insert(caDbItem->getImportParameter());
+ iDir++;
+ }
break;
default:
merr<< "Warning: unknown Certificate object type"<<endl;
@@ -300,7 +314,7 @@
backend->saveBool( accountPath + "default_account",
(*iIdent) == defaultIdentity );
-
+
backend->saveBool( accountPath + "register",
(*iIdent)->registerToProxy );
@@ -309,7 +323,7 @@
(*iIdent)->unlock();
}
-
+
accountPath = "account[" + itoa( ii ) + "]/";
/* Remove old identities remaining */
while( backend->loadString( accountPath + "account_name" ) != "" ){
@@ -326,23 +340,23 @@
backend->reset( accountPath + "transport" );
accountPath = "account[" + itoa( ++ii ) + "]/";
}
-
+
// Save soundDeviceIn in sound_device to be backward compatible.
backend->save( "sound_device", soundDeviceIn );
backend->save( "sound_device_in", soundDeviceIn );
backend->save( "sound_device_out", soundDeviceOut );
-
+
// backend->saveBool( "mute_all_but_one", muteAllButOne ); //not used anymore
-
+
backend->save( "mixer_type", soundIOmixerType );
//Save the startup commands
- list<string>::iterator iter;
+ list<string>::iterator iter;
int idx;
for( idx=0, iter = startupActions.begin();
iter != startupActions.end();
iter++, idx++ ) {
- int pos;
+ int pos;
string cmdActionsPath = string("startup_cmd[")+itoa(idx)+"]/";
pos = (*iter).find(' ');
string cmd = (*iter).substr( 0, pos );
@@ -351,7 +365,7 @@
string params = (*iter).substr( pos, (*iter).size() - pos );
backend->save( cmdActionsPath + "params", params );
}
-
+
#ifdef VIDEO_SUPPORT
backend->save( "video_device", videoDevice );
backend->save( "frame_width", frameWidth );
@@ -367,11 +381,11 @@
/************************************************************
* PhoneBooks
- ************************************************************/
+ ************************************************************/
ii = 0;
list< MRef<PhoneBook *> >::iterator iPb;
for( iPb = phonebooks.begin(); iPb != phonebooks.end(); ii++, iPb ++ ){
- backend->save( "phonebook[" + itoa(ii) + "]",
+ backend->save( "phonebook[" + itoa(ii) + "]",
(*iPb)->getPhoneBookId() );
}
@@ -388,7 +402,7 @@
}
backend->save("stun_manual_server", userDefinedStunServer);
-
+
/************************************************************
* SIP extensions
************************************************************/
@@ -402,7 +416,7 @@
backend->saveBool("tls_server", tls_server);
backend->save("ringtone", ringtone);
-
+
//add code to load the default network interface
//<network_interface> into networkInterfaceName
//We are not saving the interface name of the current localIP ...
@@ -423,7 +437,7 @@
MRef<AudioCodec *> codec = dynamic_cast<AudioCodec*>(*plugin);
if( !codec ){
- cerr << "SipSoftPhoneConfiguration: Not an AudioCodec: " << plugin->getName() << endl;
+ cerr << "SipSoftPhoneConfiguration: Not an AudioCodec: " << plugin->getName() << endl;
continue;
}
@@ -439,7 +453,7 @@
if( modified ){
int iC = 0;
list<string>::iterator iCodec;
-
+
for( iCodec = audioCodecs.begin(); iCodec != audioCodecs.end(); iCodec ++, iC++ ){
be->save( "codec[" + itoa( iC ) + "]", *iCodec );
}
@@ -465,13 +479,13 @@
//get the string version also ... don't use the itoa.h
// fileVersion_str = backend->loadString("version", "0");
if( !checkVersion( fileVersion /*, fileVersion_str*/ ) ) {
- //check version prints a message ...
+ //check version prints a message ...
//here, deal with the error
// ret = "ERROR";
saveDefault( backend );
// return ret;
}
-
+
do{
@@ -493,8 +507,8 @@
string uri = backend->loadString(accountPath + "sip_uri");
ident->setSipUri(uri);
-
-
+
+
/*From SipDialogSecurity below*/
ident->securityEnabled = backend->loadBool(accountPath + "secured");
@@ -579,7 +593,7 @@
cert->setPk( privateKeyFile );
}
catch( CertificateExceptionPkey & ){
- merr << "The given private key " << privateKeyFile << " does not match the Certificate"<<endl;
+ merr << "The given private key " << privateKeyFile << " does not match the Certificate"<<endl;
}
catch( CertificateException &){
@@ -696,11 +710,11 @@
/*From SipDialogSecurity above*/
- //
+ //
// Outbound proxy
- //
+ //
bool autodetect = backend->loadBool(accountPath + "auto_detect_proxy");
-
+
//these two values we collect them, but if autodetect is true, they are not used
string proxy = backend->loadString(accountPath + "proxy_addr","");
uint16_t proxyPort = (uint16_t)backend->loadInt(accountPath +"proxy_port", 5060);
@@ -734,8 +748,8 @@
if (registerExpires != ""){
ident->getSipRegistrar()->setRegisterExpires( registerExpires );
//set the default value ... do not change this value anymore
- ident->getSipRegistrar()->setDefaultExpires( registerExpires );
- }
+ ident->getSipRegistrar()->setDefaultExpires( registerExpires );
+ }
#ifdef DEBUG_OUTPUT
else {
//cerr << "CESC: SipSoftPhoneConf::load : NO ident expires" << endl;
@@ -766,7 +780,7 @@
string soundDevice = backend->loadString("sound_device","");
soundDeviceIn = backend->loadString("sound_device_in",soundDevice);
soundDeviceOut = backend->loadString("sound_device_out",soundDeviceIn);
-
+
soundIOmixerType = backend->loadString("mixer_type", "spatial");
// cerr << "sipconfigfile : soundiomixertype = " << soundIOmixerType << endl << endl;
@@ -789,7 +803,7 @@
// cerr << "CONFIG: startup command: " << cmd << " " << params << endl;
ii++;
}while( true );
-
+
#ifdef VIDEO_SUPPORT
videoDevice = backend->loadString( "video_device", "" );
cerr << "Loaded video_device" << videoDevice << endl;
@@ -816,9 +830,9 @@
s = backend->loadString("phonebook["+itoa(i)+"]","");
if (s!=""){
- MRef<PhoneBook *> pb;
+ MRef<PhoneBook *> pb;
pb = PhoneBookIoRegistry::getInstance()->createPhoneBook( s );
-
+
// FIXME http and other cases should go here
if( !pb.isNull() ){
phonebooks.push_back(pb);
@@ -870,7 +884,7 @@
//add code to load the default network interface
//<network_interface> into networkInterfaceName
networkInterfaceName = backend->loadString("network_interface", "");
-
+
//cerr << "EEEE: SIM: sim is "<< (sipStackConfig?"not NULL":"NULL")<< endl;
return ret;
@@ -879,13 +893,13 @@
void SipSoftPhoneConfiguration::saveDefault( MRef<ConfBackend *> be ){
//be->save( "version", CONFIG_FILE_VERSION_REQUIRED_STR );
be->save( "version", CONFIG_FILE_VERSION_REQUIRED );
-
+
#ifdef WIN32
be->save( "network_interface", "{12345678-1234-1234-12345678}" );
#else
be->save( "network_interface", "eth0" );
#endif
-
+
be->save( "account[0]/account_name", "My account" );
be->save( "account[0]/sip_uri", "username at domain.example" );
be->save( "account[0]/proxy_addr", "sip.domain.example" );
@@ -905,7 +919,7 @@
be->saveBool( "account[0]/dh_enabled", false );
be->saveBool( "account[0]/psk_enabled", false );
be->saveBool( "account[0]/check_cert", true );
-
+
be->saveBool( "tcp_server", true );
be->saveBool( "tls_server", false );
be->save( "local_udp_port", 5060 );
@@ -917,7 +931,7 @@
#else
be->save( "sound_device", "/dev/dsp" );
#endif
-
+
be->save( "mixer_type", "spatial" );
#if defined HAS_SPEEX && defined HAS_GSM
@@ -938,9 +952,9 @@
//we can save startup commands ... but do nothing by default ...
//<startup_cmd><command>call</command><params>uri</params></startup_cmd>
-
+
be->commit();
-
+
}
@@ -1008,7 +1022,7 @@
identity->lock();
- SipUri identityUri =
+ SipUri identityUri =
identity->getSipUri();
if( identityUri.getUserName() == tmpUri.getUserName() ){
Modified: trunk/libmutil/source/Timestamp.cxx
===================================================================
--- trunk/libmutil/source/Timestamp.cxx 2007-08-09 13:06:49 UTC (rev 3359)
+++ trunk/libmutil/source/Timestamp.cxx 2007-08-09 13:48:47 UTC (rev 3360)
@@ -106,7 +106,7 @@
#endif
#ifdef WIN32
- void Timestamp::print(std::string fileName){}
+ void Timestamp::print() {}
#else
void Timestamp::print() {
print(FILE_NAME);
Modified: trunk/minisip/minisip/gui/gtkgui/CertificateDialog.cxx
===================================================================
--- trunk/minisip/minisip/gui/gtkgui/CertificateDialog.cxx 2007-08-09 13:06:49 UTC (rev 3359)
+++ trunk/minisip/minisip/gui/gtkgui/CertificateDialog.cxx 2007-08-09 13:48:47 UTC (rev 3360)
@@ -26,11 +26,11 @@
#ifdef OLDLIBGLADEMM
#define SLOT(a,b) SigC::slot(a,b)
#define BIND SigC::bind
-#define MESSAGE_DIALOG_ARG Gtk::MESSAGE_WARNING,Gtk::BUTTONS_OK,false,true
+#define MESSAGE_DIALOG_ARG Gtk::MESSAGE_WARNING,Gtk::BUTTONS_OK,false,true
#else
#define SLOT(a,b) sigc::mem_fun(a,b)
#define BIND sigc::bind
-#define MESSAGE_DIALOG_ARG false,Gtk::MESSAGE_WARNING,Gtk::BUTTONS_OK,true
+#define MESSAGE_DIALOG_ARG false,Gtk::MESSAGE_WARNING,Gtk::BUTTONS_OK,true
#endif
using namespace std;
@@ -45,35 +45,35 @@
refXml->get_widget( "pkeyButton", pkeyButton );
refXml->get_widget( "certTreeView", certTreeView );
-
+
refXml->get_widget( "addCertButton", addCertButton );
refXml->get_widget( "removeCertButton", removeCertButton );
-
+
refXml->get_widget( "caTreeView", caTreeView );
refXml->get_widget( "addFileCaButton", addFileCaButton );
refXml->get_widget( "addDirCaButton", addDirCaButton );
refXml->get_widget( "removeCaButton", removeCaButton );
-
+
refXml->get_widget( "certDialog", certDialog );
-
+
refXml->get_widget( "closeButton", closeButton );
- certButton->signal_clicked().connect( SLOT( *this,
+ certButton->signal_clicked().connect( SLOT( *this,
&CertificateDialog::chooseCert ));
- pkeyButton->signal_clicked().connect( SLOT( *this,
+ pkeyButton->signal_clicked().connect( SLOT( *this,
&CertificateDialog::choosePKey ));
- addCertButton->signal_clicked().connect( SLOT( *this,
+ addCertButton->signal_clicked().connect( SLOT( *this,
&CertificateDialog::addCert ));
- removeCertButton->signal_clicked().connect( SLOT( *this,
+ removeCertButton->signal_clicked().connect( SLOT( *this,
&CertificateDialog::removeCert ));
- addFileCaButton->signal_clicked().connect( SLOT( *this,
+ addFileCaButton->signal_clicked().connect( SLOT( *this,
&CertificateDialog::addFileCa ));
- addDirCaButton->signal_clicked().connect( SLOT( *this,
+ addDirCaButton->signal_clicked().connect( SLOT( *this,
&CertificateDialog::addDirCa ));
- removeCaButton->signal_clicked().connect( SLOT( *this,
+ removeCaButton->signal_clicked().connect( SLOT( *this,
&CertificateDialog::removeCa ));
closeButton->signal_clicked().connect( SLOT( *certDialog,
@@ -81,7 +81,7 @@
certTreeStore = new CertTreeStore();
certTreeStore->associateTreeView( certTreeView );
-
+
caListStore = new CaListStore();
caListStore->associateTreeView( caTreeView );
@@ -101,7 +101,7 @@
string result;
MRef<Certificate *> chosenCert;
#ifdef OLDLIBGLADEMM
- Gtk::FileSelection * dialog = new Gtk::FileSelection(
+ Gtk::FileSelection * dialog = new Gtk::FileSelection(
"Choose your certificate file" );
#else
Gtk::FileChooserDialog * dialog = new Gtk::FileChooserDialog(
@@ -119,7 +119,7 @@
chosenCert = Certificate::load( result );
}
catch( CertificateException & exc ){
- Gtk::MessageDialog messageDialog(
+ Gtk::MessageDialog messageDialog(
"Minisip could not open that certificate file. "
"Please check that the file is a correct "
"PEM-encoded certificate.", MESSAGE_DIALOG_ARG );
@@ -138,7 +138,7 @@
certChain->clear();
certChain->addCertificate( chosenCert );
certChain->unlock();
-
+
/* Update the tree consequently */
certTreeStore->clear();
certTreeStore->addCertificate( chosenCert );
@@ -153,13 +153,13 @@
}
delete dialog;
-
+
}
void CertificateDialog::choosePKey(){
string result;
#ifdef OLDLIBGLADEMM
- Gtk::FileSelection * dialog = new Gtk::FileSelection(
+ Gtk::FileSelection * dialog = new Gtk::FileSelection(
"Choose your private key file" );
#else
Gtk::FileChooserDialog * dialog = new Gtk::FileChooserDialog(
@@ -177,7 +177,7 @@
cert->setPk( result );
}
catch( CertificateExceptionPkey & exc ){
- Gtk::MessageDialog messageDialog(
+ Gtk::MessageDialog messageDialog(
"The private key file you selected does not. "
"match the selected certificate ",
MESSAGE_DIALOG_ARG );
@@ -187,7 +187,7 @@
return;
}
catch( CertificateException & exc ){
- Gtk::MessageDialog messageDialog(
+ Gtk::MessageDialog messageDialog(
"Minisip could not open that file. "
"Please check that the file is a correct "
"PEM-encoded private key.",
@@ -213,7 +213,7 @@
MRef<Certificate *> chosenCert;
#ifdef OLDLIBGLADEMM
- Gtk::FileSelection * dialog = new Gtk::FileSelection(
+ Gtk::FileSelection * dialog = new Gtk::FileSelection(
"Choose a certificate file" );
#else
Gtk::FileChooserDialog * dialog = new Gtk::FileChooserDialog(
@@ -235,7 +235,7 @@
certChain->unlock();
}
catch( CertificateExceptionChain & exc ){
- Gtk::MessageDialog messageDialog(
+ Gtk::MessageDialog messageDialog(
"The selected certificate is not "
"assigned to the issuer of the previous "
"one.",
@@ -247,10 +247,10 @@
return;
}
catch( CertificateException & exc ){
- Gtk::MessageDialog messageDialog(
+ Gtk::MessageDialog messageDialog(
"Minisip could not open that file. "
"Please check that the file is a correct "
- "PEM-encoded certificate.",
+ "PEM-encoded certificate.",
MESSAGE_DIALOG_ARG );
certChain->unlock();
@@ -267,7 +267,7 @@
}
void CertificateDialog::removeCert(){
-
+
/* update the internal chain */
certChain->lock();
certChain->removeLast();
@@ -282,7 +282,7 @@
certLabel->set_text( "Choose a certificate..." );
pkeyLabel->set_text( "Choose a private key" );
}
-
+
certTreeStore->removeLast();
}
@@ -292,7 +292,7 @@
MRef<Certificate *> chosenCert;
#ifdef OLDLIBGLADEMM
- Gtk::FileSelection * dialog = new Gtk::FileSelection(
+ Gtk::FileSelection * dialog = new Gtk::FileSelection(
"Choose a CA file" );
#else
Gtk::FileChooserDialog * dialog = new Gtk::FileChooserDialog(
@@ -314,10 +314,10 @@
}
catch( CertificateException & exc ){
caDb->unlock();
- Gtk::MessageDialog messageDialog(
+ Gtk::MessageDialog messageDialog(
"Minisip could not open that file. "
"Please check that the file is a correct "
- "PEM-encoded certificate.",
+ "PEM-encoded certificate.",
MESSAGE_DIALOG_ARG );
messageDialog.run();
@@ -327,11 +327,11 @@
/* Update the GUI */
MRef<CertificateSetItem*> item = new CertificateSetItem();
- item->type = CERT_DB_ITEM_TYPE_FILE;
- item->item = result;
+ item->setImportMethod(CertificateSetItem::IMPORTMETHOD_FILE);
+ item->setImportParameter(result);
caListStore->addCaItem( item );
}
-
+
delete dialog;
}
@@ -340,7 +340,7 @@
MRef<Certificate *> chosenCert;
#ifdef OLDLIBGLADEMM
- Gtk::FileSelection * dialog = new Gtk::FileSelection(
+ Gtk::FileSelection * dialog = new Gtk::FileSelection(
"Choose a CA directory" );
if( dialog->get_file_list() ){
dialog->get_file_list()->get_parent()->hide();
@@ -368,9 +368,9 @@
/* Update the GUI */
MRef<CertificateSetItem*> item = new CertificateSetItem();
- item->type = CERT_DB_ITEM_TYPE_DIR;
- item->item = result;
- caListStore->addCaItem( item );
+ item->setImportMethod(CertificateSetItem::IMPORTMETHOD_DIRECTORY);
+ item->setImportParameter(result);
+ caListStore->addCaItem(item);
}
delete dialog;
@@ -379,20 +379,20 @@
void CertificateDialog::removeCa(){
MRef<CertificateSetItem*> removed;
Glib::RefPtr<Gtk::TreeSelection> selection;
-
+
selection = caTreeView->get_selection();
if( selection->count_selected_rows () == 0 ){
return;
}
-
+
Gtk::TreeModel::iterator selectedItem = selection->get_selected();
removed = caListStore->remove( selectedItem );
caDb->lock();
caDb->remove( removed );
caDb->unlock();
-
+
}
void CertificateDialog::setCertChain( MRef<CertificateChain *> chain ){
@@ -437,10 +437,10 @@
chain->unlock();
certTreeView->expand_all();
-
+
}
-
+
void CertificateDialog::setRootCa( MRef<CertificateSet *> caDb ){
@@ -505,7 +505,7 @@
void CertTreeStore::removeLast(){
Gtk::TreeModel::iterator tmp = (*lastElement).parent();
-
+
treeStore->erase( lastElement );
lastElement = tmp;
}
@@ -523,14 +523,14 @@
}
void CaListStore::addCaItem( MRef<CertificateSetItem*> caItem ){
-
+
Gtk::TreeModel::iterator iter = listStore->append();
- switch( caItem->type ){
- case CERT_DB_ITEM_TYPE_FILE:
+ switch( caItem->getImportMethod() ){
+ case CertificateSetItem::IMPORTMETHOD_FILE:
(*iter)[ typeColumn ] = "file";
break;
- case CERT_DB_ITEM_TYPE_DIR:
+ case CertificateSetItem::IMPORTMETHOD_DIRECTORY:
(*iter)[ typeColumn ] = "directory";
break;
default:
@@ -538,7 +538,7 @@
(*iter)[ typeColumn ] = "other";
}
- (*iter)[ nameColumn ] = caItem->item;
+ (*iter)[ nameColumn ] = caItem->getImportParameter();
}
void CaListStore::associateTreeView( Gtk::TreeView * treeView ){
@@ -557,17 +557,15 @@
if( (*selectedItem)[typeColumn] == "file" ){
- ret->type = CERT_DB_ITEM_TYPE_FILE;
+ ret->setImportMethod(CertificateSetItem::IMPORTMETHOD_FILE);
+ } else if( (*selectedItem)[typeColumn] == "directory" ){
+ ret->setImportMethod(CertificateSetItem::IMPORTMETHOD_DIRECTORY);
+ } else {
+ ret->setImportMethod(CertificateSetItem::IMPORTMETHOD_OTHER);
}
- else if( (*selectedItem)[typeColumn] == "directory" ){
- ret->type = CERT_DB_ITEM_TYPE_DIR;
- }
- else{
- ret->type = CERT_DB_ITEM_TYPE_OTHER;
- }
Glib::ustring toto = ((*selectedItem)[nameColumn]);
- ret->item = toto;
+ ret->setImportParameter(toto);
listStore->erase( selectedItem );
return ret;
More information about the Minisip-devel
mailing list