diff --git a/daemon/src/audio/audiorecord.cpp b/daemon/src/audio/audiorecord.cpp index 24226265a5348748a53ea0f35e551915f6d4b10b..4b85829cc089332ddf0702a94b93f381e5e7dca5 100644 --- a/daemon/src/audio/audiorecord.cpp +++ b/daemon/src/audio/audiorecord.cpp @@ -29,7 +29,7 @@ */ #include "audiorecord.h" -#include <cstring> // for strstr +#include <unistd.h> #include <sstream> // for stringstream // structure for the wave header @@ -50,7 +50,6 @@ struct wavhdr { SINT32 data_length; // in bytes }; - AudioRecord::AudioRecord() : fileHandle_(NULL) , fileType_(FILE_INVALID) , channels_(1) @@ -63,6 +62,7 @@ AudioRecord::AudioRecord() : fileHandle_(NULL) , mixBuffer_(new SFLDataFormat[nbSamplesMax_]) , micBuffer_(new SFLDataFormat[nbSamplesMax_]) , spkBuffer_(new SFLDataFormat[nbSamplesMax_]) + , filename_() , savePath_() { createFilename(); @@ -93,21 +93,19 @@ void AudioRecord::setRecordingOption(FILE_TYPE type, int sndSmplRate, const std: savePath_ = path + "/"; } - - -void AudioRecord::initFileName(std::string peerNumber) +void AudioRecord::initFilename(const std::string &peerNumber) { - std::string fName = fileName_; + std::string fName(filename_); fName.append("-" + peerNumber); if (fileType_ == FILE_RAW) { - if (strstr(fileName_, ".raw") == NULL) { - DEBUG("AudioRecord: concatenate .raw file extension: name : %s", fileName_); + if (filename_.find(".raw") == std::string::npos) { + DEBUG("AudioRecord: concatenate .raw file extension: name : %s", filename_.c_str()); fName.append(".raw"); } } else if (fileType_ == FILE_WAV) { - if (strstr(fileName_, ".wav") == NULL) { - DEBUG("AudioRecord: concatenate .wav file extension: name : %s", fileName_); + if (filename_.find(".wav") == std::string::npos) { + DEBUG("AudioRecord: concatenate .wav file extension: name : %s", filename_.c_str()); fName.append(".wav"); } } @@ -115,7 +113,7 @@ void AudioRecord::initFileName(std::string peerNumber) savePath_.append(fName); } -std::string AudioRecord::getFileName() +std::string AudioRecord::getFilename() const { return savePath_; } @@ -145,7 +143,6 @@ bool AudioRecord::openFile() return result; } - void AudioRecord::closeFile() { if (fileHandle_ == 0) return; @@ -153,20 +150,17 @@ void AudioRecord::closeFile() if (fileType_ == FILE_RAW) fclose(fileHandle_); else if (fileType_ == FILE_WAV) - this->closeWavFile(); + closeWavFile(); } - -bool AudioRecord::isOpenFile() +bool AudioRecord::isOpenFile() const { return fileHandle_ != 0; } - -bool AudioRecord::fileExists() +bool AudioRecord::fileExists() const { - DEBUG("AudioRecord: Trying to open %s ", fileName_); - return fopen(fileName_,"rb") != 0; + return access(savePath_.c_str(), F_OK) != -1; } bool AudioRecord::isRecording() const @@ -174,7 +168,6 @@ bool AudioRecord::isRecording() const return recordingEnabled_; } - bool AudioRecord::setRecording() { if (isOpenFile()) { @@ -201,7 +194,6 @@ void AudioRecord::stopRecording() recordingEnabled_ = false; } - void AudioRecord::createFilename() { time_t rawtime; @@ -214,7 +206,7 @@ void AudioRecord::createFilename() std::stringstream out; // DATE - out << timeinfo->tm_year+1900; + out << timeinfo->tm_year + 1900; if (timeinfo->tm_mon < 9) // january is 01, not 1 out << 0; @@ -247,11 +239,9 @@ void AudioRecord::createFilename() out << 0; out << timeinfo->tm_sec; + filename_ = out.str(); - // fileName_ = out.str(); - strncpy(fileName_, out.str().c_str(), 8192); - - DEBUG("AudioRecord: create filename for this call %s ", fileName_); + DEBUG("AudioRecord: create filename for this call %s ", filename_.c_str()); } bool AudioRecord::setRawFile() @@ -268,7 +258,6 @@ bool AudioRecord::setRawFile() return true; } - bool AudioRecord::setWavFile() { DEBUG("AudioRecord: Create new wave file %s, sampling rate: %d", savePath_.c_str(), sndSmplRate_); @@ -311,10 +300,9 @@ bool AudioRecord::setWavFile() return true; } - bool AudioRecord::openExistingRawFile() { - fileHandle_ = fopen(fileName_, "ab+"); + fileHandle_ = fopen(filename_.c_str(), "ab+"); if (!fileHandle_) { WARN("AudioRecord: could not create RAW file!"); @@ -324,12 +312,11 @@ bool AudioRecord::openExistingRawFile() return true; } - bool AudioRecord::openExistingWavFile() { - DEBUG("%s(%s)\n", __PRETTY_FUNCTION__, fileName_); + DEBUG("%s(%s)\n", __PRETTY_FUNCTION__, filename_.c_str()); - fileHandle_ = fopen(fileName_, "rb+"); + fileHandle_ = fopen(filename_.c_str(), "rb+"); if (!fileHandle_) { WARN("AudioRecord: Error: could not open WAV file!"); @@ -349,7 +336,7 @@ bool AudioRecord::openExistingWavFile() if (fclose(fileHandle_) != 0) WARN("AudioRecord: Error: Can't close file r+ "); - fileHandle_ = fopen(fileName_, "ab+"); + fileHandle_ = fopen(filename_.c_str(), "ab+"); if (!fileHandle_) { WARN("AudioRecord: Error: Could not createopen WAV file ab+!"); @@ -410,7 +397,6 @@ void AudioRecord::recSpkrData(SFLDataFormat* buffer, int nSamples) } } - void AudioRecord::recMicData(SFLDataFormat* buffer, int nSamples) { if (recordingEnabled_) { @@ -422,7 +408,6 @@ void AudioRecord::recMicData(SFLDataFormat* buffer, int nSamples) } } - void AudioRecord::recData(SFLDataFormat* buffer, int nSamples) { if (recordingEnabled_) { @@ -440,7 +425,6 @@ void AudioRecord::recData(SFLDataFormat* buffer, int nSamples) } } - void AudioRecord::recData(SFLDataFormat* buffer_1, SFLDataFormat* buffer_2, int nSamples_1, int /*nSamples_2*/) { diff --git a/daemon/src/audio/audiorecord.h b/daemon/src/audio/audiorecord.h index d865a5509e44a40190b832a58ef980886e85918d..03a9f6a7d3d274ea4976b30674165d804471f756 100644 --- a/daemon/src/audio/audiorecord.h +++ b/daemon/src/audio/audiorecord.h @@ -57,16 +57,16 @@ class AudioRecord { /** * Init recording file path */ - void initFileName(std::string peerNumber); + void initFilename(const std::string &peerNumber); /** * Return the filepath of the recording */ - std::string getFileName(); + std::string getFilename() const; /** * Check if no otehr file is opened, then create a new one - * @param fileName A string containing teh file (with/without extension) + * @param filename A string containing teh file (with/without extension) * @param type The sound file format (FILE_RAW, FILE_WAVE) * @param format Internal sound format (INT16 / INT32) * @return bool True if file was opened @@ -81,12 +81,12 @@ class AudioRecord { /** * Check if a file is already opened */ - bool isOpenFile(); + bool isOpenFile() const; /** * Check if a file already exists */ - bool fileExists(); + bool fileExists() const; /** * Check recording state @@ -231,7 +231,7 @@ class AudioRecord { /** * Filename for this recording */ - char fileName_[8192]; + std::string filename_; /** * Path for this recording diff --git a/daemon/src/audio/recordable.cpp b/daemon/src/audio/recordable.cpp index b55b4ed7cbece13b86170dab909459d3c14bdb50..71f5d00d6b0991220b060b1c069a54ef7c5584bb 100644 --- a/daemon/src/audio/recordable.cpp +++ b/daemon/src/audio/recordable.cpp @@ -30,33 +30,33 @@ #include "recordable.h" #include "manager.h" -Recordable::Recordable() : recAudio(), recorder(&recAudio, Manager::instance().getMainBuffer()) +Recordable::Recordable() : recAudio_(), recorder_(&recAudio_, Manager::instance().getMainBuffer()) { - recAudio.setRecordingOption(AudioRecord::FILE_WAV, 8000, Manager::instance().audioPreference.getRecordpath()); + recAudio_.setRecordingOption(AudioRecord::FILE_WAV, 8000, Manager::instance().audioPreference.getRecordpath()); } Recordable::~Recordable() { - if (recAudio.isOpenFile()) - recAudio.closeFile(); + if (recAudio_.isOpenFile()) + recAudio_.closeFile(); } -void Recordable::initRecFileName(std::string filename) +void Recordable::initRecFilename(const std::string &filename) { - recAudio.initFileName(filename); + recAudio_.initFilename(filename); } -std::string Recordable::getFileName() +std::string Recordable::getFilename() const { - return recAudio.getFileName(); + return recAudio_.getFilename(); } void Recordable::setRecordingSmplRate(int smplRate) { - recAudio.setSndSamplingRate(smplRate); + recAudio_.setSndSamplingRate(smplRate); } int Recordable::getRecordingSmplRate() const { - return recAudio.getSndSamplingRate(); + return recAudio_.getSndSamplingRate(); } diff --git a/daemon/src/audio/recordable.h b/daemon/src/audio/recordable.h index 13effb2ef53da4eee22c724a3ddbc3dbc08dc6c2..7df25c5365aa23a8c184e26fe8757d123c718814 100644 --- a/daemon/src/audio/recordable.h +++ b/daemon/src/audio/recordable.h @@ -43,8 +43,8 @@ class Recordable { /** * Return recording state (true/false) */ - bool isRecording() { - return recAudio.isRecording(); + bool isRecording() const { + return recAudio_.isRecording(); } /** @@ -57,18 +57,18 @@ class Recordable { * Stop recording */ void stopRecording() { - recAudio.stopRecording(); + recAudio_.stopRecording(); } /** * Init the recording file name according to path specified in configuration */ - void initRecFileName(std::string filename); + void initRecFilename(const std::string &filename); /** * Return the file path for this recording */ - std::string getFileName(); + virtual std::string getFilename() const; /** * Set recording sampling rate. @@ -82,16 +82,13 @@ class Recordable { /** * Virtual method to be implemented in order to the main - * buffer to retreive the recorded id. + * buffer to retrieve the recorded id. */ virtual std::string getRecFileId() const = 0; - /** - * An instance of audio recorder - */ - AudioRecord recAudio; - - AudioRecorder recorder; + protected: + AudioRecord recAudio_; + AudioRecorder recorder_; }; #endif diff --git a/daemon/src/call.cpp b/daemon/src/call.cpp index 73ccbe36548f9c39acb521b111988e7098d2517e..a1d1c4e29fe1350dd04468f19a6e07c49761fdbc 100644 --- a/daemon/src/call.cpp +++ b/daemon/src/call.cpp @@ -31,6 +31,7 @@ #include "call.h" #include "manager.h" #include "audio/mainbuffer.h" +#include "history/historyitem.h" const char * const Call::DEFAULT_ID = "audiolayer_id"; @@ -41,13 +42,16 @@ Call::Call(const std::string& id, Call::CallType type) , id_(id) , confID_() , type_(type) - , connectionState_(Call::Disconnected) - , callState_(Call::Inactive) + , connectionState_(Call::DISCONNECTED) + , callState_(Call::INACTIVE) , isIPToIP_(false) - , peerName_() , peerNumber_() , displayName_() -{} + , timestamp_start_(0) + , timestamp_stop_(0) +{ + time(×tamp_start_); +} Call::~Call() {} @@ -66,7 +70,6 @@ Call::getConnectionState() return connectionState_; } - void Call::setState(CallState state) { @@ -85,34 +88,34 @@ std::string Call::getStateStr() { switch (getState()) { - case Active: + case ACTIVE: switch (getConnectionState()) { - case Ringing: + case RINGING: return isIncoming() ? "INCOMING" : "RINGING"; - case Connected: + case CONNECTED: default: return isRecording() ? "RECORD" : "CURRENT"; } - case Hold: + case HOLD: return "HOLD"; - case Busy: + case BUSY: return "BUSY"; - case Inactive: + case INACTIVE: switch (getConnectionState()) { - case Ringing: + case RINGING: return isIncoming() ? "INCOMING" : "RINGING"; - case Connected: + case CONNECTED: return "CURRENT"; default: return "INACTIVE"; } - case Conferencing: + case CONFERENCING: return "CONFERENCING"; - case Refused: - case Error: + case REFUSED: + case ERROR: default: return "FAILURE"; } @@ -136,17 +139,17 @@ Call::getLocalAudioPort() bool Call::setRecording() { - bool recordStatus = Recordable::recAudio.isRecording(); + bool recordStatus = Recordable::recAudio_.isRecording(); - Recordable::recAudio.setRecording(); + Recordable::recAudio_.setRecording(); MainBuffer *mbuffer = Manager::instance().getMainBuffer(); - std::string process_id = Recordable::recorder.getRecorderID(); + std::string process_id = Recordable::recorder_.getRecorderID(); if (!recordStatus) { mbuffer->bindHalfDuplexOut(process_id, id_); mbuffer->bindHalfDuplexOut(process_id); - Recordable::recorder.start(); + Recordable::recorder_.start(); } else { mbuffer->unBindHalfDuplexOut(process_id, id_); mbuffer->unBindHalfDuplexOut(process_id); @@ -156,3 +159,41 @@ Call::setRecording() return recordStatus; } + +void Call::time_stop() +{ + time(×tamp_stop_); +} + +std::string Call::getTypeStr() const +{ + switch (type_) { + case INCOMING: + return "incoming"; + case OUTGOING: + return "outgoing"; + case MISSED: + return "missed"; + default: + return ""; + } +} + +std::map<std::string, std::string> Call::createHistoryEntry() const +{ + std::map<std::string, std::string> result; + result[HistoryItem::ACCOUNT_ID_KEY] = Manager::instance().getAccountFromCall(id_); + result[HistoryItem::CONFID_KEY] = confID_; + result[HistoryItem::CALLID_KEY] = id_; + result[HistoryItem::DISPLAY_NAME_KEY] = displayName_; + result[HistoryItem::PEER_NUMBER_KEY] = peerNumber_; + result[HistoryItem::RECORDING_PATH_KEY] = recAudio_.fileExists() ? getFilename() : ""; + std::stringstream time_str; + time_str << timestamp_start_; + result[HistoryItem::TIMESTAMP_START_KEY] = time_str.str(); + time_str.str(""); + time_str << timestamp_stop_; + result[HistoryItem::TIMESTAMP_STOP_KEY] = time_str.str(); + result[HistoryItem::STATE_KEY] = getTypeStr(); + return result; +} diff --git a/daemon/src/call.h b/daemon/src/call.h index 18d754f557f49b9c6c0206f75c864623f9ec3ef6..f746c787d4a8ae192ca171ba6d4d607971cc9a07 100644 --- a/daemon/src/call.h +++ b/daemon/src/call.h @@ -47,10 +47,10 @@ class Call : public Recordable { static const char * const DEFAULT_ID; /** - * This determines if the call originated from the local user (Outgoing) - * or from some remote peer (Incoming). + * This determines if the call originated from the local user (OUTGOING) + * or from some remote peer (INCOMING, MISSED). */ - enum CallType {Incoming, Outgoing}; + enum CallType {INCOMING, OUTGOING, MISSED}; /** * Tell where we're at with the call. The call gets Connected when we know @@ -60,12 +60,12 @@ class Call : public Recordable { * Audio should be transmitted when ConnectionState = Connected AND * CallState = Active. */ - enum ConnectionState {Disconnected, Trying, Progressing, Ringing, Connected}; + enum ConnectionState {DISCONNECTED, TRYING, PROGRESSING, RINGING, CONNECTED}; /** * The Call State. */ - enum CallState {Inactive, Active, Hold, Busy, Conferencing, Refused, Error}; + enum CallState {INACTIVE, ACTIVE, HOLD, BUSY, CONFERENCING, REFUSED, ERROR}; /** * Constructor of a call @@ -117,24 +117,6 @@ class Call : public Recordable { return peerNumber_; } - /** - * Set the peer name (caller in ingoing) - * not protected by mutex (when created) - * @param name The peer name - */ - void setPeerName(const std::string& name) { - peerName_ = name; - } - - /** - * Get the peer name (caller in ingoing) - * not protected by mutex (when created) - * @return std::string The peer name - */ - std::string getPeerName() const { - return peerName_; - } - /** * Set the display name (caller in ingoing) * not protected by mutex (when created) @@ -158,8 +140,8 @@ class Call : public Recordable { * @return true if yes * false otherwise */ - bool isIncoming() { - return type_ == Incoming; + bool isIncoming() const { + return type_ == INCOMING; } /** @@ -225,16 +207,15 @@ class Call : public Recordable { unsigned int getLocalAudioPort(); std::string getRecFileId() const { - return getPeerName(); - } - - std::string getFileName() const { - return peerNumber_; + return getDisplayName(); } + void time_stop(); + std::map<std::string, std::string> createHistoryEntry() const; virtual bool setRecording(); private: + std::string getTypeStr() const; /** Protect every attribute that can be changed by two threads */ ost::Mutex callMutex_; @@ -264,14 +245,14 @@ class Call : public Recordable { /** Direct IP-to-IP or classic call */ bool isIPToIP_; - /** Name of the peer */ - std::string peerName_; - /** Number of the peer */ std::string peerNumber_; /** Display Name */ std::string displayName_; + + time_t timestamp_start_; + time_t timestamp_stop_; }; #endif diff --git a/daemon/src/conference.cpp b/daemon/src/conference.cpp index fc37157b582898a800a3fff06fccaa70689b1f5d..d40da64e58d3e9642801456af5c7409aff7b3137 100644 --- a/daemon/src/conference.cpp +++ b/daemon/src/conference.cpp @@ -41,7 +41,7 @@ Conference::Conference() , confState_(ACTIVE_ATTACHED) , participants_() { - Recordable::initRecFileName(id_); + Recordable::initRecFilename(id_); } int Conference::getState() const @@ -101,12 +101,12 @@ ParticipantSet Conference::getParticipantList() const bool Conference::setRecording() { - bool recordStatus = Recordable::recAudio.isRecording(); + bool recordStatus = Recordable::recAudio_.isRecording(); - Recordable::recAudio.setRecording(); + Recordable::recAudio_.setRecording(); MainBuffer *mbuffer = Manager::instance().getMainBuffer(); - std::string process_id(Recordable::recorder.getRecorderID()); + std::string process_id(Recordable::recorder_.getRecorderID()); // start recording if (!recordStatus) { @@ -115,7 +115,7 @@ bool Conference::setRecording() mbuffer->bindHalfDuplexOut(process_id); - Recordable::recorder.start(); + Recordable::recorder_.start(); } else { for (ParticipantSet::const_iterator iter = participants_.begin(); iter != participants_.end(); ++iter) mbuffer->unBindHalfDuplexOut(process_id, *iter); diff --git a/daemon/src/dbus/configurationmanager-introspec.xml b/daemon/src/dbus/configurationmanager-introspec.xml index 6271c12c9d3cedfc8f6c286d7d199b5b51e1e386..1934dc3f72d731ba900764faf7ac4d10bcf0833d 100644 --- a/daemon/src/dbus/configurationmanager-introspec.xml +++ b/daemon/src/dbus/configurationmanager-introspec.xml @@ -607,12 +607,6 @@ <arg type="aa{ss}" name="entries" direction="out"/> </method> - <method name="setHistory" tp:name-for-bindings="setHistory"> - <annotation name="com.trolltech.QtDBus.QtTypeName.In0" value="VectorMapStringString"/> - <arg type="aa{ss}" name="entries" direction="in"> - </arg> - </method> - <signal name="accountsChanged" tp:name-for-bindings="accountsChanged"> </signal> diff --git a/daemon/src/dbus/configurationmanager.cpp b/daemon/src/dbus/configurationmanager.cpp index aec8f5e881e48f1e6e088ee1bca06f6dd5c026cf..e8a494e1d427a1c7214174618ad2f497021c7545 100644 --- a/daemon/src/dbus/configurationmanager.cpp +++ b/daemon/src/dbus/configurationmanager.cpp @@ -59,8 +59,8 @@ std::map<std::string, std::string> ConfigurationManager::getIp2IpDetails() return sipaccount->getIp2IpDetails(); std::map<std::string, std::string> tlsSettings = getTlsSettings(); - std::copy(tlsSettings.begin(), tlsSettings.end(), std::inserter( - ip2ipAccountDetails, ip2ipAccountDetails.end())); + std::copy(tlsSettings.begin(), tlsSettings.end(), + std::inserter(ip2ipAccountDetails, ip2ipAccountDetails.end())); return ip2ipAccountDetails; } @@ -155,7 +155,7 @@ std::vector<std::string> ConfigurationManager::getAccountList() * Send the list of all codecs loaded to the client through DBus. * Can stay global, as only the active codecs will be set per accounts */ -std::vector<int32_t > ConfigurationManager::getAudioCodecList() +std::vector<int32_t> ConfigurationManager::getAudioCodecList() { std::vector<int32_t> list(Manager::instance().audioCodecFactory.getAudioCodecList()); @@ -403,11 +403,6 @@ std::vector<std::map<std::string, std::string> > ConfigurationManager::getHistor return Manager::instance().getHistory(); } -void ConfigurationManager::setHistory(const std::vector<std::map<std::string, std::string> > &entries) -{ - Manager::instance().setHistorySerialized(entries); -} - std::string ConfigurationManager::getAddrFromInterfaceName(const std::string& interface) { diff --git a/daemon/src/dbus/configurationmanager.h b/daemon/src/dbus/configurationmanager.h index 9264c886bc12ff6334d58ef4ddfcbaec0030fc9c..2f77eca68025c80d7561d3fa98d06bfd0d6d585a 100644 --- a/daemon/src/dbus/configurationmanager.h +++ b/daemon/src/dbus/configurationmanager.h @@ -68,7 +68,7 @@ class ConfigurationManager : void removeAccount(const std::string& accoundID); void deleteAllCredential(const std::string& accountID); std::vector< std::string > getAccountList(); - void sendRegister(const std::string& accoundID , const int32_t& expire); + void sendRegister(const std::string& accoundID, const int32_t& expire); std::map< std::string, std::string > getTlsSettingsDefault(); @@ -124,7 +124,6 @@ class ConfigurationManager : void setHookSettings(const std::map<std::string, std::string>& settings); std::vector<std::map<std::string, std::string> > getHistory(); - void setHistory(const std::vector<std::map<std::string, std::string> > &entries); std::map<std::string, std::string> getTlsSettings(); void setTlsSettings(const std::map< std::string, std::string >& details); diff --git a/daemon/src/history/history.cpp b/daemon/src/history/history.cpp index 5f08256058f80824e829f0f4fafd09092c06018c..08964fcd95aa0b5869f1b9f71233728fee488606 100644 --- a/daemon/src/history/history.cpp +++ b/daemon/src/history/history.cpp @@ -32,11 +32,12 @@ #include "history.h" #include <cerrno> -#include <cc++/file.h> #include <algorithm> +#include <sys/stat.h> // for mkdir #include <ctime> #include "global.h" #include "logger.h" +#include "call.h" namespace { int oldestAllowed(int days) @@ -54,27 +55,28 @@ namespace { } History::History() : - items_(), loaded_(false), path_("") + items_(), path_("") {} -void History::load(int limit) +bool History::load(int limit) { ensurePath(); std::ifstream infile(path_.c_str()); if (!infile) { DEBUG("No history file to load"); - return; + return false; } while (!infile.eof()) { HistoryItem item(infile); - addNewEntry(item, limit); + addEntry(item, limit); } - loaded_ = true; + return true; } bool History::save() { DEBUG("History: Saving history in XDG directory: %s", path_.c_str()); + ensurePath(); std::sort(items_.begin(), items_.end()); std::ofstream outfile(path_.c_str()); if (outfile.fail()) @@ -85,10 +87,12 @@ bool History::save() return true; } -void History::addNewEntry(const HistoryItem &item, int oldest) +void History::addEntry(const HistoryItem &item, int oldest) { - if (item.hasPeerNumber() and item.youngerThan(oldest)) + if (item.hasPeerNumber() and item.youngerThan(oldest)) { + DEBUG("Adding history item"); items_.push_back(item); + } } void History::ensurePath() @@ -117,7 +121,6 @@ void History::ensurePath() } } - vector<map<string, string> > History::getSerialized() const { vector<map<string, string> > result; @@ -128,19 +131,18 @@ vector<map<string, string> > History::getSerialized() const return result; } -void History::setSerialized(const vector<map<string, string> > &history, - int limit) +void History::setPath(const std::string &path) { - items_.clear(); - const int oldest = oldestAllowed(limit); - for (vector<map<string, string> >::const_iterator iter = history.begin(); - iter != history.end(); ++iter) { - HistoryItem item(*iter); - addNewEntry(item, oldest); - } + path_ = path; } -void History::setPath(const std::string &path) +void History::addCall(Call *call, int limit) { - path_ = path; + if (!call) { + ERROR("History: Call is NULL, ignoring"); + return; + } + call->time_stop(); + HistoryItem item(call->createHistoryEntry()); + addEntry(item, limit); } diff --git a/daemon/src/history/history.h b/daemon/src/history/history.h index 81b541559227f574f1e16c0db61d788cec11ab82..99827a849ae664caea20d85639403c39471b48d6 100644 --- a/daemon/src/history/history.h +++ b/daemon/src/history/history.h @@ -36,33 +36,23 @@ #include "historyitem.h" #include <vector> +class Call; + class History { public: - /* - * Constructor - */ History(); - /** - * Load history from file - */ - void load(int limit); + /** Load history from file */ + bool load(int limit); /** - *@return bool True if the history has been successfully saved in the file + *@return True if the history has been successfully saved in the file */ bool save(); - /** - *@return bool True if the history file has been successfully read - */ - bool isLoaded() const { - return loaded_; - } - /* - *@return int The number of items found in the history file + *@return The number of items found in the history file */ size_t numberOfItems() const { return items_.size(); @@ -74,30 +64,23 @@ class History { std::vector<std::map<std::string, std::string> > getSerialized() const; - // FIXME:tmatth:get rid of this - void setSerialized(const std::vector<std::map<std::string, std::string> > &history, int limit); - + void addCall(Call *call, int limit); private: void setPath(const std::string &path); + /* If no path has been set, this will initialize path to a + * system-dependent location */ void ensurePath(); /* * Add a new history item in the data structure */ - void addNewEntry(const HistoryItem &new_item, int limit); + void addEntry(const HistoryItem &new_item, int limit); /* * Vector containing the history items */ std::vector<HistoryItem> items_; - /* - * History has been loaded - */ - bool loaded_; - - /* - * The path to the history file - */ + /* The path to the history file */ std::string path_; friend class HistoryTest; diff --git a/daemon/src/history/historyitem.cpp b/daemon/src/history/historyitem.cpp index ee4eb3fd1334c78a452702599251e3daa684cf3d..cfcc1c461a6a95a8209054f59a6f38466c165f33 100644 --- a/daemon/src/history/historyitem.cpp +++ b/daemon/src/history/historyitem.cpp @@ -37,7 +37,7 @@ const char * const HistoryItem::ACCOUNT_ID_KEY = "accountid"; const char * const HistoryItem::CALLID_KEY = "callid"; const char * const HistoryItem::CONFID_KEY = "confid"; -const char * const HistoryItem::PEER_NAME_KEY = "peer_name"; +const char * const HistoryItem::DISPLAY_NAME_KEY = "display_name"; const char * const HistoryItem::PEER_NUMBER_KEY = "peer_number"; const char * const HistoryItem::RECORDING_PATH_KEY = "recordfile"; const char * const HistoryItem::STATE_KEY = "state"; diff --git a/daemon/src/history/historyitem.h b/daemon/src/history/historyitem.h index 7aa71085dc0b79cbebcaf1bc4e1c113f61a855cb..3f7e1e5143215cefc002648cfa81f13cacdc7957 100644 --- a/daemon/src/history/historyitem.h +++ b/daemon/src/history/historyitem.h @@ -41,7 +41,7 @@ class HistoryItem { static const char * const ACCOUNT_ID_KEY; static const char * const CONFID_KEY; static const char * const CALLID_KEY; - static const char * const PEER_NAME_KEY; + static const char * const DISPLAY_NAME_KEY; static const char * const PEER_NUMBER_KEY; static const char * const RECORDING_PATH_KEY; static const char * const TIMESTAMP_START_KEY; diff --git a/daemon/src/iax/iaxvoiplink.cpp b/daemon/src/iax/iaxvoiplink.cpp index f8e10cb1e15f1d942e9ed41b3a925c56529cf3ae..1f926e7790c825f91303165cd438e9ada4c5f7fb 100644 --- a/daemon/src/iax/iaxvoiplink.cpp +++ b/daemon/src/iax/iaxvoiplink.cpp @@ -142,7 +142,7 @@ IAXVoIPLink::sendAudioFromMic() for (CallMap::const_iterator iter = callMap_.begin(); iter != callMap_.end() ; ++iter) { IAXCall *currentCall = dynamic_cast<IAXCall*>(iter->second); - if (!currentCall or currentCall->getState() != Call::Active) + if (!currentCall or currentCall->getState() != Call::ACTIVE) continue; int codecType = currentCall->getAudioCodec(); @@ -240,14 +240,14 @@ IAXVoIPLink::sendUnregister(Account *a) Call* IAXVoIPLink::newOutgoingCall(const std::string& id, const std::string& toUrl) { - IAXCall* call = new IAXCall(id, Call::Outgoing); + IAXCall* call = new IAXCall(id, Call::OUTGOING); call->setPeerNumber(toUrl); - call->initRecFileName(toUrl); + call->initRecFilename(toUrl); iaxOutgoingInvite(call); - call->setConnectionState(Call::Progressing); - call->setState(Call::Active); + call->setConnectionState(Call::PROGRESSING); + call->setState(Call::ACTIVE); addCall(call); return call; @@ -265,8 +265,8 @@ IAXVoIPLink::answer(Call *c) iax_answer(call->session); mutexIAX_.leave(); - call->setState(Call::Active); - call->setConnectionState(Call::Connected); + call->setState(Call::ACTIVE); + call->setConnectionState(Call::CONNECTED); Manager::instance().getMainBuffer()->flushAllBuffers(); } @@ -326,7 +326,7 @@ IAXVoIPLink::onhold(const std::string& id) iax_quelch_moh(call->session, true); mutexIAX_.leave(); - call->setState(Call::Hold); + call->setState(Call::HOLD); } void @@ -343,7 +343,7 @@ IAXVoIPLink::offhold(const std::string& id) iax_unquelch(call->session); mutexIAX_.leave(); Manager::instance().getAudioDriver()->startStream(); - call->setState(Call::Active); + call->setState(Call::ACTIVE); } void @@ -468,8 +468,8 @@ IAXVoIPLink::iaxHandleCallEvent(iax_event* event, IAXCall* call) break; case IAX_EVENT_REJECT: - call->setConnectionState(Call::Connected); - call->setState(Call::Error); + call->setConnectionState(Call::CONNECTED); + call->setState(Call::ERROR); Manager::instance().callFailure(id); removeCall(id); break; @@ -484,13 +484,13 @@ IAXVoIPLink::iaxHandleCallEvent(iax_event* event, IAXCall* call) case IAX_EVENT_ANSWER: case IAX_EVENT_TRANSFER: - if (call->getConnectionState() == Call::Connected) + if (call->getConnectionState() == Call::CONNECTED) break; Manager::instance().addStream(call->getCallId()); - call->setConnectionState(Call::Connected); - call->setState(Call::Active); + call->setConnectionState(Call::CONNECTED); + call->setState(Call::ACTIVE); if (event->ies.format) call->format = event->ies.format; @@ -503,8 +503,8 @@ IAXVoIPLink::iaxHandleCallEvent(iax_event* event, IAXCall* call) break; case IAX_EVENT_BUSY: - call->setConnectionState(Call::Connected); - call->setState(Call::Busy); + call->setConnectionState(Call::CONNECTED); + call->setState(Call::BUSY); Manager::instance().callBusy(id); removeCall(id); break; @@ -518,7 +518,7 @@ IAXVoIPLink::iaxHandleCallEvent(iax_event* event, IAXCall* call) break; case IAX_EVENT_RINGA: - call->setConnectionState(Call::Ringing); + call->setConnectionState(Call::RINGING); Manager::instance().peerRingingCall(call->getCallId()); break; @@ -608,18 +608,18 @@ void IAXVoIPLink::iaxHandlePrecallEvent(iax_event* event) case IAX_EVENT_CONNECT: id = Manager::instance().getNewCallID(); - call = new IAXCall(id, Call::Incoming); + call = new IAXCall(id, Call::INCOMING); call->session = event->session; - call->setConnectionState(Call::Progressing); + call->setConnectionState(Call::PROGRESSING); if (event->ies.calling_number) call->setPeerNumber(event->ies.calling_number); if (event->ies.calling_name) - call->setPeerName(std::string(event->ies.calling_name)); + call->setDisplayName(std::string(event->ies.calling_name)); // if peerNumber exist append it to the name string - call->initRecFileName(std::string(event->ies.calling_number)); + call->initRecFilename(std::string(event->ies.calling_number)); Manager::instance().incomingCall(call, accountID_); format = call->getFirstMatchingFormat(event->ies.format, accountID_); diff --git a/daemon/src/main.cpp b/daemon/src/main.cpp index ad6cd9fb9c536c92f26fd678a4bd1939eceda211..4423af4177b99330d2f468da80faf8a478f4685f 100644 --- a/daemon/src/main.cpp +++ b/daemon/src/main.cpp @@ -155,6 +155,7 @@ main(int argc, char **argv) DEBUG("Starting DBus event loop"); Manager::instance().getDbusManager()->exec(); + Manager::instance().saveHistory(); return 0; } diff --git a/daemon/src/managerimpl.cpp b/daemon/src/managerimpl.cpp index f9ed343fcf9c9a06ac9648e64f8067454c0d40dd..e5505c897c27c94c8f83ec6a943b96d036bf5710 100644 --- a/daemon/src/managerimpl.cpp +++ b/daemon/src/managerimpl.cpp @@ -374,13 +374,18 @@ void ManagerImpl::hangupCall(const std::string& callId) if (isIPToIP(callId)) { /* Direct IP to IP call */ try { + Call * call = SIPVoIPLink::instance()->getCall(callId); + history_->addCall(call, preferences.getHistoryLimit()); SIPVoIPLink::instance()->hangup(callId); } catch (const VoipLinkException &e) { ERROR("%s", e.what()); } } else { std::string accountId(getAccountFromCall(callId)); - getAccountLink(accountId)->hangup(callId); + VoIPLink *link = getAccountLink(accountId); + Call * call = link->getCall(callId); + history_->addCall(call, preferences.getHistoryLimit()); + link->hangup(callId); removeCallAccount(callId); } @@ -524,19 +529,21 @@ bool ManagerImpl::transferCall(const std::string& callId, const std::string& to) removeParticipant(callId); Conference *conf = getConferenceFromCallID(callId); processRemainingParticipants(callId, conf); - } else if (not isConference(getCurrentCallId())) + } else if (not isConference(getCurrentCallId())) { switchCall(""); + } // Direct IP to IP call - if (isIPToIP(callId)) + if (isIPToIP(callId)) { SIPVoIPLink::instance()->transfer(callId, to); - else { - std::string accountid(getAccountFromCall(callId)); + } else { + std::string accountID(getAccountFromCall(callId)); - if (accountid.empty()) + if (accountID.empty()) return false; - getAccountLink(accountid)->transfer(callId, to); + VoIPLink *link = getAccountLink(accountID); + link->transfer(callId, to); } // remove waiting call in case we make transfer without even answer @@ -1384,13 +1391,13 @@ void ManagerImpl::incomingCall(Call* call, const std::string& accountId) } if (not hasCurrentCall()) { - call->setConnectionState(Call::Ringing); + call->setConnectionState(Call::RINGING); ringtone(accountId); } addWaitingCall(call->getCallId()); - std::string from(call->getPeerName()); + std::string from(call->getDisplayName()); std::string number(call->getPeerNumber()); if (not from.empty() and not number.empty()) @@ -1568,11 +1575,17 @@ void ManagerImpl::peerHungupCall(const std::string& call_id) } /* Direct IP to IP call */ - if (isIPToIP(call_id)) + if (isIPToIP(call_id)) { + Call * call = SIPVoIPLink::instance()->getCall(call_id); + history_->addCall(call, preferences.getHistoryLimit()); SIPVoIPLink::instance()->hangup(call_id); + } else { const std::string account_id(getAccountFromCall(call_id)); - getAccountLink(account_id)->peerHungup(call_id); + VoIPLink *link = getAccountLink(account_id); + Call * call = link->getCall(call_id); + history_->addCall(call, preferences.getHistoryLimit()); + link->peerHungup(call_id); } /* Broadcast a signal over DBus */ @@ -1874,7 +1887,7 @@ std::string ManagerImpl::getCurrentCodecName(const std::string& id) if (call) { Call::CallState state = call->getState(); - if (state == Call::Active or state == Call::Conferencing) + if (state == Call::ACTIVE or state == Call::CONFERENCING) codecName = link->getCurrentCodecName(call); } @@ -2077,7 +2090,7 @@ void ManagerImpl::setRecordingCall(const std::string& id) } rec->setRecording(); - dbus_.getCallManager()->recordPlaybackFilepath(id, rec->getFileName()); + dbus_.getCallManager()->recordPlaybackFilepath(id, rec->getFilename()); } bool ManagerImpl::isRecording(const std::string& id) @@ -2867,7 +2880,6 @@ std::map<std::string, std::string> ManagerImpl::getCallDetails(const std::string type << call->getCallType(); call_details["ACCOUNTID"] = accountid; call_details["PEER_NUMBER"] = call->getPeerNumber(); - call_details["PEER_NAME"] = call->getPeerName(); call_details["DISPLAY_NAME"] = call->getDisplayName(); call_details["CALL_STATE"] = call->getStateStr(); call_details["CALL_TYPE"] = type.str(); @@ -2889,12 +2901,6 @@ std::vector<std::map<std::string, std::string> > ManagerImpl::getHistory() const return history_->getSerialized(); } -void ManagerImpl::setHistorySerialized(const std::vector<std::map<std::string, std::string> > &history) -{ - history_->setSerialized(history, preferences.getHistoryLimit()); - history_->save(); -} - namespace { template <typename M, typename V> void vectorFromMapKeys(const M &m, V &v) @@ -2945,3 +2951,9 @@ std::vector<std::string> ManagerImpl::getParticipantList(const std::string& conf return v; } + +void ManagerImpl::saveHistory() +{ + if (!history_->save()) + ERROR("Manager: could not save history!"); +} diff --git a/daemon/src/managerimpl.h b/daemon/src/managerimpl.h index f17e4b62c7670ab77b59f66aabcc5ec93864ab1f..8d12afe0a0d0cc250b7e0afff3d25c0efee7bac8 100644 --- a/daemon/src/managerimpl.h +++ b/daemon/src/managerimpl.h @@ -413,7 +413,7 @@ class ManagerImpl { * 0 for unregistration request * 1 for registration request */ - void sendRegister(const ::std::string& accountId , const int32_t& enable); + void sendRegister(const std::string& accountId , const int32_t& enable); /** * Get account list @@ -1186,6 +1186,7 @@ class ManagerImpl { * Send registration to all enabled accounts */ void registerAccounts(); + void saveHistory(); private: NON_COPYABLE(ManagerImpl); diff --git a/daemon/src/sip/sipvoiplink.cpp b/daemon/src/sip/sipvoiplink.cpp index 28aaa2baaf46c3610793da8227cb0844d87fdf5c..5564a55809f1a77a2a452c09afe97fb9866db740 100644 --- a/daemon/src/sip/sipvoiplink.cpp +++ b/daemon/src/sip/sipvoiplink.cpp @@ -381,7 +381,7 @@ Call *SIPVoIPLink::newOutgoingCall(const std::string& id, const std::string& toU if (account == NULL) // TODO: We should investigate how we could get rid of this error and create a IP2IP call instead throw VoipLinkException("Could not get account for this call"); - SIPCall* call = new SIPCall(id, Call::Outgoing, cp_); + SIPCall* call = new SIPCall(id, Call::OUTGOING, cp_); // If toUri is not a well formated sip URI, use account information to process it std::string toUri; @@ -428,7 +428,7 @@ Call *SIPVoIPLink::newOutgoingCall(const std::string& id, const std::string& toU throw VoipLinkException("Could not start rtp session for early media"); } - call->initRecFileName(toUrl); + call->initRecFilename(toUrl); call->getLocalSDP()->setLocalIP(addrSdp); call->getLocalSDP()->createOffer(account->getActiveCodecs()); @@ -457,8 +457,8 @@ SIPVoIPLink::answer(Call *c) if (pjsip_inv_send_msg(call->inv, tdata) != PJ_SUCCESS) throw VoipLinkException("Could not send invite request answer (200 OK)"); - call->setConnectionState(Call::Connected); - call->setState(Call::Active); + call->setConnectionState(Call::CONNECTED); + call->setState(Call::ACTIVE); } void @@ -528,7 +528,7 @@ void SIPVoIPLink::onhold(const std::string& id) { SIPCall *call = getSIPCall(id); - call->setState(Call::Hold); + call->setState(Call::HOLD); call->getAudioRtp().stop(); Sdp *sdpSession = call->getLocalSDP(); @@ -580,7 +580,7 @@ SIPVoIPLink::offhold(const std::string& id) sdpSession->addAttributeToLocalAudioMedia("sendrecv"); if (SIPSessionReinvite(call) == PJ_SUCCESS) - call->setState(Call::Active); + call->setState(Call::ACTIVE); } void @@ -696,7 +696,7 @@ SIPVoIPLink::refuse(const std::string& id) { SIPCall *call = getSIPCall(id); - if (!call->isIncoming() or call->getConnectionState() == Call::Connected) + if (!call->isIncoming() or call->getConnectionState() == Call::CONNECTED) return; call->getAudioRtp().stop(); @@ -818,8 +818,8 @@ SIPVoIPLink::SIPStartCall(SIPCall *call) if (pjsip_inv_send_msg(call->inv, tdata) != PJ_SUCCESS) return false; - call->setConnectionState(Call::Progressing); - call->setState(Call::Active); + call->setConnectionState(Call::PROGRESSING); + call->setState(Call::ACTIVE); addCall(call); return true; @@ -848,9 +848,9 @@ SIPVoIPLink::SIPCallClosed(SIPCall *call) void SIPVoIPLink::SIPCallAnswered(SIPCall *call, pjsip_rx_data *rdata UNUSED) { - if (call->getConnectionState() != Call::Connected) { - call->setConnectionState(Call::Connected); - call->setState(Call::Active); + if (call->getConnectionState() != Call::CONNECTED) { + call->setConnectionState(Call::CONNECTED); + call->setState(Call::ACTIVE); Manager::instance().peerAnsweredCall(call->getCallId()); } } @@ -874,9 +874,9 @@ bool SIPVoIPLink::SIPNewIpToIpCall(const std::string& id, const std::string& to) if (!account) return false; - SIPCall *call = new SIPCall(id, Call::Outgoing, cp_); + SIPCall *call = new SIPCall(id, Call::OUTGOING, cp_); call->setIPToIP(true); - call->initRecFileName(to); + call->initRecFilename(to); std::string localAddress(getInterfaceAddrFromName(account->getLocalInterface())); @@ -1307,7 +1307,7 @@ void invite_session_state_changed_cb(pjsip_inv_session *inv, pjsip_event *e) } if (inv->state == PJSIP_INV_STATE_EARLY and e->body.tsx_state.tsx->role == PJSIP_ROLE_UAC) { - call->setConnectionState(Call::Ringing); + call->setConnectionState(Call::RINGING); Manager::instance().peerRingingCall(call->getCallId()); } else if (inv->state == PJSIP_INV_STATE_CONFIRMED) { // After we sent or received a ACK - The connection is established @@ -1744,7 +1744,7 @@ static pj_bool_t transaction_request_cb(pjsip_rx_data *rdata) UrlHook::runAction(Manager::instance().hookPreference.getUrlCommand(), header_value); } - SIPCall* call = new SIPCall(Manager::instance().getNewCallID(), Call::Incoming, cp_); + SIPCall* call = new SIPCall(Manager::instance().getNewCallID(), Call::INCOMING, cp_); Manager::instance().associateCallToAccount(call->getCallId(), account_id); // May use the published address as well @@ -1766,10 +1766,10 @@ static pj_bool_t transaction_request_cb(pjsip_rx_data *rdata) std::string peerNumber(tmp, length); stripSipUriPrefix(peerNumber); - call->setConnectionState(Call::Progressing); + call->setConnectionState(Call::PROGRESSING); call->setPeerNumber(peerNumber); call->setDisplayName(displayName); - call->initRecFileName(peerNumber); + call->initRecFilename(peerNumber); setCallMediaLocal(call, addrToUse); @@ -1854,7 +1854,7 @@ static pj_bool_t transaction_request_cb(pjsip_rx_data *rdata) PJ_ASSERT_RETURN(pjsip_inv_initial_answer(call->inv, rdata, PJSIP_SC_RINGING, NULL, NULL, &tdata) == PJ_SUCCESS, 1); PJ_ASSERT_RETURN(pjsip_inv_send_msg(call->inv, tdata) == PJ_SUCCESS, 1); - call->setConnectionState(Call::Ringing); + call->setConnectionState(Call::RINGING); Manager::instance().incomingCall(call, account_id); Manager::instance().getAccountLink(account_id)->addCall(call); diff --git a/daemon/test/historytest.cpp b/daemon/test/historytest.cpp index a92430aafe5e760bbaccd3d5bd30d7981c50bff6..1c6ec3596cf47fef70163e357ed7123df42e6bf4 100644 --- a/daemon/test/historytest.cpp +++ b/daemon/test/historytest.cpp @@ -67,7 +67,6 @@ void HistoryTest::test_create_path() DEBUG("-------------------- HistoryTest::test_set_path --------------------\n"); std::string path(HISTORY_SAMPLE); - CPPUNIT_ASSERT(!history_->isLoaded()); CPPUNIT_ASSERT(history_->path_ == path); } @@ -75,16 +74,15 @@ void HistoryTest::test_load_from_file() { DEBUG("-------------------- HistoryTest::test_load_from_file --------------------\n"); - history_->load(HISTORY_LIMIT); - - CPPUNIT_ASSERT(history_->isLoaded()); + bool res = history_->load(HISTORY_LIMIT); + CPPUNIT_ASSERT(res); } void HistoryTest::test_load_items() { DEBUG("-------------------- HistoryTest::test_load_items --------------------\n"); - history_->load(HISTORY_LIMIT); - CPPUNIT_ASSERT(history_->isLoaded()); + bool res = history_->load(HISTORY_LIMIT); + CPPUNIT_ASSERT(res); CPPUNIT_ASSERT(history_->numberOfItems() == HISTORY_SAMPLE_SIZE); } @@ -97,8 +95,8 @@ void HistoryTest::test_save_to_file() void HistoryTest::test_get_serialized() { DEBUG("-------------------- HistoryTest::test_get_serialized --------------------\n"); - history_->load(HISTORY_LIMIT); - CPPUNIT_ASSERT(history_->isLoaded()); + bool res = history_->load(HISTORY_LIMIT); + CPPUNIT_ASSERT(res); CPPUNIT_ASSERT(history_->getSerialized().size() == HISTORY_SAMPLE_SIZE); } diff --git a/gnome/src/actions.c b/gnome/src/actions.c index d19abd2dcd4651ad1e0f3b224f7ee675e477e861..1ae2fa57dc3d90d29c7256825c9e7e0ad6eb70ec 100644 --- a/gnome/src/actions.c +++ b/gnome/src/actions.c @@ -142,9 +142,6 @@ void sflphone_quit() { if (calllist_get_size(current_calls_tab) == 0 || main_window_ask_quit()) { - // Save the history - sflphone_save_history(); - dbus_unregister(getpid()); dbus_clean(); account_list_free(); @@ -828,7 +825,7 @@ static int place_registered_call(callable_obj_t * c) void sflphone_place_call(callable_obj_t * c) { - DEBUG("Actions: Placing call with %s @ %s and accountid %s", c->_peer_name, c->_peer_number, c->_accountID); + DEBUG("Actions: Placing call with %s @ %s and accountid %s", c->_display_name, c->_peer_number, c->_accountID); if (_is_direct_call(c)) { gchar *msg = g_markup_printf_escaped(_("Direct SIP call")); @@ -1057,32 +1054,6 @@ void sflphone_fill_history(void) fill_treeview_with_calls(); } -void sflphone_save_history(void) -{ - gint size = calllist_get_size(history_tab); - - GPtrArray *history_array = g_ptr_array_new(); - /* For each entry in our call history */ - for (gint i = 0; i < size; ++i) { - QueueElement *current = calllist_get_nth(history_tab, i); - - if (!current) { - WARN("SFLphone: Warning: %dth element is null", i); - break; - } - - if (current->type == HIST_CALL) { - GHashTable *value = create_hashtable_from_history_entry(current->elem.call); - g_ptr_array_add(history_array, (gpointer) value); - } - else - ERROR("SFLphone: Error: Unknown type for serialization"); - } - - dbus_set_history(history_array); - g_ptr_array_free(history_array, TRUE); -} - void sflphone_srtp_sdes_on(callable_obj_t * c) { diff --git a/gnome/src/actions.h b/gnome/src/actions.h index 203460e49964973b719701f8bdc570538d9a26b0..efb2fe2f93b86f3ba830fcec044dfea94339de4e 100644 --- a/gnome/src/actions.h +++ b/gnome/src/actions.h @@ -201,8 +201,6 @@ void status_bar_display_account (); void sflphone_fill_history (void); -void sflphone_save_history (void); - /** * Action called when a new participant is dragged in */ diff --git a/gnome/src/callable_obj.c b/gnome/src/callable_obj.c index 8b4f4aac62344d244b36ddb0afdca2b415e2b6d8..1044b4ddabc3e94613d7bbacf478029fe4334b17 100644 --- a/gnome/src/callable_obj.c +++ b/gnome/src/callable_obj.c @@ -46,7 +46,7 @@ gint get_state_callstruct(gconstpointer a, gconstpointer b) return c->_state == state ? 0 : 1; } -gchar* call_get_peer_name(const gchar *format) +gchar* call_get_display_name(const gchar *format) { const gchar *end = g_strrstr(format, "<"); return g_strndup(format, end ? end - format : 0); @@ -115,7 +115,7 @@ void call_remove_all_errors(callable_obj_t * call) callable_obj_t *create_new_call(callable_type_t type, call_state_t state, const gchar* const callID, const gchar* const accountID, - const gchar* const peer_name, + const gchar* const display_name, const gchar* const peer_number) { callable_obj_t *obj = g_new0(callable_obj_t, 1); @@ -129,9 +129,9 @@ callable_obj_t *create_new_call(callable_type_t type, call_state_t state, time(&obj->_time_start); time(&obj->_time_stop); - obj->_peer_name = g_strdup(peer_name); + obj->_display_name = g_strdup(display_name); obj->_peer_number = g_strdup(peer_number); - obj->_peer_info = get_peer_info(peer_name, peer_number); + obj->_peer_info = get_peer_info(display_name, peer_number); return obj; } @@ -142,7 +142,7 @@ callable_obj_t *create_new_call_from_details(const gchar *call_id, GHashTable *d const gchar * const accountID = g_hash_table_lookup(details, "ACCOUNTID"); const gchar * const peer_number = g_hash_table_lookup(details, "PEER_NUMBER"); - const gchar * const peer_name = g_hash_table_lookup(details, "DISPLAY_NAME"); + const gchar * const display_name = g_hash_table_lookup(details, "DISPLAY_NAME"); const gchar * const state_str = g_hash_table_lookup(details, "CALL_STATE"); if (g_strcasecmp(state_str, "CURRENT") == 0) @@ -159,7 +159,7 @@ callable_obj_t *create_new_call_from_details(const gchar *call_id, GHashTable *d state = CALL_STATE_FAILURE; gchar *number = call_get_peer_number(peer_number); - callable_obj_t *c = create_new_call(CALL, state, call_id, accountID, peer_name, number); + callable_obj_t *c = create_new_call(CALL, state, call_id, accountID, display_name, number); g_free(number); return c; } @@ -176,19 +176,19 @@ static gconstpointer get_str(GHashTable *entry, gconstpointer key) static const char * const ACCOUNT_ID_KEY = "accountid"; static const char * const CALLID_KEY = "callid"; static const char * const CONFID_KEY = "confid"; -static const char * const PEER_NAME_KEY = "peer_name"; +static const char * const DISPLAY_NAME_KEY = "display_name"; static const char * const PEER_NUMBER_KEY = "peer_number"; static const char * const RECORDING_PATH_KEY = "recordfile"; -static const char * const TIMESTAMP_STOP_KEY = "timestamp_stop"; static const char * const STATE_KEY = "state"; +static const char * const TIMESTAMP_STOP_KEY = "timestamp_stop"; callable_obj_t *create_history_entry_from_hashtable(GHashTable *entry) { gconstpointer callID = get_str(entry, CALLID_KEY); gconstpointer accountID = get_str(entry, ACCOUNT_ID_KEY); - gconstpointer peer_name = get_str(entry, PEER_NAME_KEY); + gconstpointer display_name = get_str(entry, DISPLAY_NAME_KEY); gconstpointer peer_number = get_str(entry, PEER_NUMBER_KEY); - callable_obj_t *new_call = create_new_call(HISTORY_ENTRY, CALL_STATE_DIALING, callID, accountID, peer_name, peer_number); + callable_obj_t *new_call = create_new_call(HISTORY_ENTRY, CALL_STATE_DIALING, callID, accountID, display_name, peer_number); new_call->_history_state = g_strdup(get_str(entry, STATE_KEY)); gconstpointer value = g_hash_table_lookup(entry, TIMESTAMP_START_KEY); new_call->_time_start = value ? atoi(value) : 0; @@ -210,7 +210,7 @@ void free_callable_obj_t (callable_obj_t *c) g_free(c->_accountID); g_free(c->_srtp_cipher); g_free(c->_sas); - g_free(c->_peer_name); + g_free(c->_display_name); g_free(c->_peer_number); g_free(c->_trsft_to); g_free(c->_peer_info); @@ -249,7 +249,7 @@ GHashTable* create_hashtable_from_history_entry(callable_obj_t *entry) const gchar *call_id = entry->_callID ? entry->_callID : ""; const gchar *peer_number = entry->_peer_number ? entry->_peer_number : ""; - const gchar *peer_name = (entry->_peer_name && *entry->_peer_name) ? entry->_peer_name : "empty"; + const gchar *display_name = (entry->_display_name && *entry->_display_name) ? entry->_display_name : "empty"; const gchar *account_id = (entry->_accountID && *entry->_accountID) ? entry->_accountID : "empty"; const gchar *conf_id = entry->_historyConfID ? entry->_historyConfID : ""; @@ -259,7 +259,7 @@ GHashTable* create_hashtable_from_history_entry(callable_obj_t *entry) add_to_hashtable(result, ACCOUNT_ID_KEY, account_id); add_to_hashtable(result, CALLID_KEY, call_id); add_to_hashtable(result, CONFID_KEY, conf_id); - add_to_hashtable(result, PEER_NAME_KEY, peer_name); + add_to_hashtable(result, DISPLAY_NAME_KEY, display_name); add_to_hashtable(result, PEER_NUMBER_KEY, peer_number); add_to_hashtable(result, RECORDING_PATH_KEY, recording_path); add_to_hashtable(result, STATE_KEY, history_state); diff --git a/gnome/src/callable_obj.h b/gnome/src/callable_obj.h index 849ec7783d662ec7dc1a927fdc025cd731d7a711..6f66b76b6bfa72a9b586bbdb0223e5937c526410 100644 --- a/gnome/src/callable_obj.h +++ b/gnome/src/callable_obj.h @@ -112,7 +112,7 @@ typedef struct { /** * The information about the person we are talking */ - gchar *_peer_name; + gchar *_display_name; gchar *_peer_number; /** @@ -183,7 +183,7 @@ gint get_state_callstruct(gconstpointer, gconstpointer); * @param c The call * @return The full name of the caller or an empty string */ -gchar* call_get_peer_name(const gchar*); +gchar* call_get_display_name(const gchar*); /** * This function parse the callable_obj_t.from field to return the number diff --git a/gnome/src/contacts/calltree.c b/gnome/src/contacts/calltree.c index 3ccf76705a13aa832e10b7cd02121b6202665ebf..c36271dcbb822ac2a446dfb66d7f2536822eef35 100644 --- a/gnome/src/contacts/calltree.c +++ b/gnome/src/contacts/calltree.c @@ -211,7 +211,7 @@ row_activated(GtkTreeView *tree_view UNUSED, } } else { // If history or contact: double click action places a new call - callable_obj_t* new_call = create_new_call(CALL, CALL_STATE_DIALING, "", selectedCall->_accountID, selectedCall->_peer_name, selectedCall->_peer_number); + callable_obj_t* new_call = create_new_call(CALL, CALL_STATE_DIALING, "", selectedCall->_accountID, selectedCall->_display_name, selectedCall->_peer_number); calllist_add_call(current_calls_tab, new_call); calltree_add_call(current_calls_tab, new_call, NULL); @@ -351,8 +351,8 @@ calltree_display_call_info(callable_obj_t * c, CallDisplayType display_type, con // Different display depending on type const gchar *name, *details = NULL; - if (*c->_peer_name) { - name = c->_peer_name; + if (*c->_display_name) { + name = c->_display_name; details = display_number; } else { name = display_number; diff --git a/gnome/src/dbus/configurationmanager-introspec.xml b/gnome/src/dbus/configurationmanager-introspec.xml index 6271c12c9d3cedfc8f6c286d7d199b5b51e1e386..1934dc3f72d731ba900764faf7ac4d10bcf0833d 100644 --- a/gnome/src/dbus/configurationmanager-introspec.xml +++ b/gnome/src/dbus/configurationmanager-introspec.xml @@ -607,12 +607,6 @@ <arg type="aa{ss}" name="entries" direction="out"/> </method> - <method name="setHistory" tp:name-for-bindings="setHistory"> - <annotation name="com.trolltech.QtDBus.QtTypeName.In0" value="VectorMapStringString"/> - <arg type="aa{ss}" name="entries" direction="in"> - </arg> - </method> - <signal name="accountsChanged" tp:name-for-bindings="accountsChanged"> </signal> diff --git a/gnome/src/dbus/dbus.c b/gnome/src/dbus/dbus.c index 54512daa4d3e893ee2e05ca36d3081c7f069d609..9363ea42f7f8dabb101f476faa2941e6d4603fbf 100644 --- a/gnome/src/dbus/dbus.c +++ b/gnome/src/dbus/dbus.c @@ -73,13 +73,13 @@ incoming_call_cb(DBusGProxy *proxy UNUSED, const gchar* accountID, const gchar* callID, const gchar* from, void * foo UNUSED) { // We receive the from field under a formatted way. We want to extract the number and the name of the caller - gchar *peer_name = call_get_peer_name(from); + gchar *display_name = call_get_display_name(from); gchar *peer_number = call_get_peer_number(from); - callable_obj_t *c = create_new_call(CALL, CALL_STATE_INCOMING, callID, accountID, peer_name, peer_number); + callable_obj_t *c = create_new_call(CALL, CALL_STATE_INCOMING, callID, accountID, display_name, peer_number); g_free(peer_number); - g_free(peer_name); + g_free(display_name); status_tray_icon_blink(TRUE); popup_main_window(); @@ -1958,20 +1958,6 @@ dbus_get_history(void) return entries; } -void -dbus_set_history(const GPtrArray *entries) -{ - GError *error = NULL; - - org_sflphone_SFLphone_ConfigurationManager_set_history( - configurationManagerProxy, entries, &error); - - if (error) { - ERROR("Error calling org_sflphone_SFLphone_ConfigurationlManager_set_history"); - g_error_free(error); - } -} - void dbus_confirm_sas(const callable_obj_t * c) { diff --git a/gnome/src/dbus/dbus.h b/gnome/src/dbus/dbus.h index 8ff9027cb9e0a27a05f77bc7639565aa0bf37393..a9b266f9e53061b6842555cecbc2726194986903 100644 --- a/gnome/src/dbus/dbus.h +++ b/gnome/src/dbus/dbus.h @@ -477,13 +477,6 @@ void dbus_set_accounts_order (const gchar* order); */ GPtrArray *dbus_get_history(void); -/** - * Set the history entries into the daemon. The daemon then writes the content - * of this list into the history file - * @param A list of serialized history entries - */ -void dbus_set_history (const GPtrArray *history); - void sflphone_display_transfer_status (const gchar* message); /** diff --git a/gnome/src/imwindow.c b/gnome/src/imwindow.c index 9b170a22c7a8bb87eaa9fc992f356a9680b01dc2..d7841631faf03ba3e6d63419bd60e6b08e31e444 100644 --- a/gnome/src/imwindow.c +++ b/gnome/src/imwindow.c @@ -206,7 +206,7 @@ im_window_add_tab(IMWidget *im) im->tab = tab_container; if (im_widget_call) - tab_label = gtk_label_new(*im_widget_call->_peer_name ? im_widget_call->_peer_name : im_widget_call->_peer_number); + tab_label = gtk_label_new(*im_widget_call->_display_name ? im_widget_call->_display_name : im_widget_call->_peer_number); else if (im_widget_conf) tab_label = gtk_label_new("Conferencing"); else diff --git a/gnome/src/uimanager.c b/gnome/src/uimanager.c index d2525525520cfdcce8c4150660feb48748e6285e..2431e911d7deb935c4e4b07a454f03224c7059d9 100644 --- a/gnome/src/uimanager.c +++ b/gnome/src/uimanager.c @@ -800,7 +800,7 @@ call_back(void * foo UNUSED) } callable_obj_t *new_call = create_new_call(CALL, CALL_STATE_DIALING, "", - "", selected_call->_peer_name, + "", selected_call->_display_name, selected_call->_peer_number); calllist_add_call(current_calls_tab, new_call); @@ -895,7 +895,7 @@ edit_paste(void * foo UNUSED) gchar * temp = g_strconcat(selectedCall->_peer_number, oneNo, NULL); g_free(selectedCall->_peer_info); - selectedCall->_peer_info = get_peer_info(temp, selectedCall->_peer_name); + selectedCall->_peer_info = get_peer_info(temp, selectedCall->_display_name); g_free(temp); g_free(oneNo); calltree_update_call(current_calls_tab, selectedCall); @@ -1483,7 +1483,7 @@ ok_cb(GtkWidget *widget UNUSED, gpointer userdata) // Create the new call callable_obj_t *modified_call = create_new_call(CALL, CALL_STATE_DIALING, "", original->_accountID, - original->_peer_name, new_number); + original->_display_name, new_number); // Update the internal data structure and the GUI calllist_add_call(current_calls_tab, modified_call); diff --git a/gnome/src/widget/imwidget.c b/gnome/src/widget/imwidget.c index adb83b4473d9da8a702b4cb18347029ff1a5f96c..764d73e40a1462a1a87d8f93f3ff13c9a1018ca1 100644 --- a/gnome/src/widget/imwidget.c +++ b/gnome/src/widget/imwidget.c @@ -344,7 +344,7 @@ im_widget_infobar(IMWidget *im) gchar *msg1; if (im_widget_call) - msg1 = g_strdup_printf("Calling %s %s", im_widget_call->_peer_number, im_widget_call->_peer_name); + msg1 = g_strdup_printf("Calling %s %s", im_widget_call->_peer_number, im_widget_call->_display_name); else if (im_widget_conf) msg1 = g_strdup_printf("Conferencing"); else diff --git a/kde/src/dbus/configurationmanager-introspec.xml b/kde/src/dbus/configurationmanager-introspec.xml index 6271c12c9d3cedfc8f6c286d7d199b5b51e1e386..1934dc3f72d731ba900764faf7ac4d10bcf0833d 100755 --- a/kde/src/dbus/configurationmanager-introspec.xml +++ b/kde/src/dbus/configurationmanager-introspec.xml @@ -607,12 +607,6 @@ <arg type="aa{ss}" name="entries" direction="out"/> </method> - <method name="setHistory" tp:name-for-bindings="setHistory"> - <annotation name="com.trolltech.QtDBus.QtTypeName.In0" value="VectorMapStringString"/> - <arg type="aa{ss}" name="entries" direction="in"> - </arg> - </method> - <signal name="accountsChanged" tp:name-for-bindings="accountsChanged"> </signal>