~ubuntu-branches/ubuntu/trusty/sflphone/trusty

« back to all changes in this revision

Viewing changes to daemon/src/history/historyitem.cpp

  • Committer: Package Import Robot
  • Author(s): Mark Purcell
  • Date: 2013-06-30 11:40:56 UTC
  • mfrom: (4.1.18 saucy-proposed)
  • Revision ID: package-import@ubuntu.com-20130630114056-0np50jkyqo6vnmii
Tags: 1.2.3-2
* changeset_r92d62cfc54732bbbcfff2b1d36c096b120b981a5.diff 
  - fixes automatic endian detection 
* Update Vcs: fixes vcs-field-not-canonical

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 *  Copyright (C) 2004, 2005, 2006, 2008, 2009, 2010, 2011 Savoir-Faire Linux Inc.
 
2
 *  Copyright (C) 2004-2012 Savoir-Faire Linux Inc.
3
3
 *
4
4
 *  Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com>
5
5
 *  Author: Alexandre Savard <alexandre.savard@savoirfairelinux.com>
16
16
 *
17
17
 *  You should have received a copy of the GNU General Public License
18
18
 *  along with this program; if not, write to the Free Software
19
 
 *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
19
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.
20
20
 *
21
21
 *  Additional permission under GNU GPL version 3 section 7:
22
22
 *
31
31
 */
32
32
 
33
33
#include "historyitem.h"
 
34
#include <unistd.h>
34
35
#include <cstdlib>
35
36
#include <istream>
36
37
 
 
38
namespace sfl {
 
39
 
37
40
const char * const HistoryItem::ACCOUNT_ID_KEY =        "accountid";
38
41
const char * const HistoryItem::CALLID_KEY =            "callid";
39
42
const char * const HistoryItem::CONFID_KEY =            "confid";
43
46
const char * const HistoryItem::STATE_KEY =             "state";
44
47
const char * const HistoryItem::TIMESTAMP_START_KEY =   "timestamp_start";
45
48
const char * const HistoryItem::TIMESTAMP_STOP_KEY =    "timestamp_stop";
 
49
const char * const HistoryItem::AUDIO_CODEC_KEY =       "audio_codec";
 
50
const char * const HistoryItem::VIDEO_CODEC_KEY =       "video_codec";
46
51
 
47
52
const char * const HistoryItem::MISSED_STRING =         "missed";
48
53
const char * const HistoryItem::INCOMING_STRING =       "incoming";
51
56
using std::map;
52
57
using std::string;
53
58
 
 
59
namespace {
 
60
    bool file_exists(const std::string &str)
 
61
    {
 
62
        return access(str.c_str(), F_OK) != -1;
 
63
    }
 
64
}
 
65
 
54
66
HistoryItem::HistoryItem(const map<string, string> &args) : entryMap_(args),
55
67
    timestampStart_(std::atol(entryMap_[TIMESTAMP_START_KEY].c_str()))
56
68
{}
65
77
        else if (pos < tmp.length() - 1) {
66
78
            string key(tmp.substr(0, pos));
67
79
            string val(tmp.substr(pos + 1, tmp.length() - pos - 1));
 
80
            if (key == RECORDING_PATH_KEY and not file_exists(val))
 
81
                val = "";
68
82
            entryMap_[key] = val;
69
83
        }
70
84
    }
90
104
{
91
105
    // every entry starts with "[" + random integer = "]"
92
106
    for (map<string, string>::const_iterator iter = entryMap_.begin();
93
 
         iter != entryMap_.end(); ++iter)
94
 
        o << iter->first << "=" << iter->second << std::endl;
 
107
         iter != entryMap_.end(); ++iter) {
 
108
        // if the file does not exist anymore, we do not save it
 
109
        if (iter->first == RECORDING_PATH_KEY and not file_exists(iter->second))
 
110
            o << iter->first << "=" << "" << std::endl;
 
111
        else
 
112
            o << iter->first << "=" << iter->second << std::endl;
 
113
    }
95
114
}
96
115
 
97
116
std::ostream& operator << (std::ostream& o, const HistoryItem& item)
99
118
    item.print(o);
100
119
    return o;
101
120
}
 
121
 
 
122
}