~noskcaj/ubuntu/saucy/sflphone/merge-1.2.3-2

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Mark Purcell
  • Date: 2012-05-19 21:46:37 UTC
  • mfrom: (1.1.7)
  • Revision ID: package-import@ubuntu.com-20120519214637-la8rbrford5kj6m3
Tags: 1.1.0-1
* New upstream release 
  - Fixes "FTBFS with libccrtp-dev/2.0.2 from experimental" (Closes: #663282)
* NEW Maintainer: Debian VoIP Team - Thanks Francois for your work.
  - (Closes: #665789: O: sflphone -- SIP and IAX2 compatible VoIP phone)
* Added Build-Depends: libdbus-c++-bin
* Add gcc47-fixes.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
#include "history.h"
34
34
#include <cerrno>
35
35
#include <algorithm>
 
36
#include <fstream>
36
37
#include <sys/stat.h> // for mkdir
37
38
#include <ctime>
38
 
#include "global.h"
 
39
#include "fileutils.h"
39
40
#include "logger.h"
40
41
#include "call.h"
41
42
 
42
 
namespace {
43
 
    int oldestAllowed(int days)
44
 
    {
45
 
        time_t currentTimestamp;
46
 
        time(&currentTimestamp);
47
 
        // Number of seconds in one day: 60 sec/min x 60 min/hr x 24hr/day
48
 
        static const int DAY_UNIX_TIMESTAMP = 60 * 60 * 24;
49
 
        return static_cast<int>(currentTimestamp) - (days * DAY_UNIX_TIMESTAMP);
50
 
    }
51
 
 
52
 
    using std::map;
53
 
    using std::string;
54
 
    using std::vector;
55
 
}
56
 
 
57
 
History::History() :
58
 
    items_(), path_("")
 
43
using std::map;
 
44
using std::string;
 
45
using std::vector;
 
46
 
 
47
History::History() : items_(), path_("")
59
48
{}
60
49
 
61
50
bool History::load(int limit)
75
64
 
76
65
bool History::save()
77
66
{
78
 
    DEBUG("History: Saving history in XDG directory: %s", path_.c_str());
 
67
    DEBUG("Saving history in XDG directory: %s", path_.c_str());
79
68
    ensurePath();
80
69
    std::sort(items_.begin(), items_.end());
81
70
    std::ofstream outfile(path_.c_str());
110
99
        if (mkdir(userdata.data(), 0755) != 0) {
111
100
            // If directory     creation failed
112
101
            if (errno != EEXIST) {
113
 
                DEBUG("History: Cannot create directory: %m");
 
102
                DEBUG("Cannot create directory: %m");
114
103
                return;
115
104
            }
116
105
        }
137
126
void History::addCall(Call *call, int limit)
138
127
{
139
128
    if (!call) {
140
 
        ERROR("History: Call is NULL, ignoring");
 
129
        ERROR("Call is NULL, ignoring");
141
130
        return;
142
131
    }
143
132
    call->time_stop();