1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
/*
* Copyright 2012-2013 Samsung Electronics Co., Ltd
*
* Licensed under the Flora License, Version 1.1 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "Search/ContactLogRecord.h"
#include "phone.h"
#include "phone-common.h"
#include "Database/Database.h"
namespace Phone
{
namespace Dialer
{
namespace Search
{
using Database::Database;
ContactLogRecord::ContactLogRecord()
{
PH_TRACE;
}
ContactLogRecord::ContactLogRecord(const ContactLogRecord &other)
: ContactData(other)
{
PH_TRACE;
}
bool ContactLogRecord::initialize(int id)
{
PH_TRACE;
contacts_query_h query = NULL;
contacts_filter_h filter = NULL;
contacts_list_h list = NULL;
contacts_record_h record = NULL;
unsigned ids[] = {
_contacts_person_phone_log.person_id,
_contacts_person_phone_log.address,
};
bool success = Database::isSuccess(
contacts_filter_create(_contacts_person_phone_log._uri, &filter))
&& Database::isSuccess(
contacts_filter_add_int(filter, _contacts_person_phone_log.log_id, CONTACTS_MATCH_EQUAL, id))
&& Database::isSuccess(
contacts_query_create(_contacts_person_phone_log._uri, &query))
&& Database::isSuccess(
contacts_query_set_filter(query, filter))
&& Database::isSuccess(
contacts_query_set_projection(query, ids, sizeof(ids) / sizeof(*ids)))
&& Database::isSuccess(
contacts_db_get_records_with_query(query, 0, 0, &list))
&& Database::isSuccess(
contacts_list_get_current_record_p(list, &record))
&& initialize(record);
if(filter)
{
contacts_filter_destroy(filter);
}
if(query)
{
contacts_query_destroy(query);
}
if(list)
{
contacts_list_destroy(list, true);
}
return success;
}
bool ContactLogRecord::initialize(contacts_record_h record)
{
PH_TRACE;
char *number = NULL;
int id = 0;
bool success = Database::isSuccess(
contacts_record_get_str_p(record, _contacts_person_phone_log.address, &number))
&& Database::isSuccess(
contacts_record_get_int(record, _contacts_person_phone_log.person_id, &id));
if(success)
{
m_Number.clear();
if(number)
{
m_Number = number;
}
m_PersonId = id;
}
return success;
}
int ContactLogRecord::getPersonId() const
{
return m_PersonId;
}
ContactLogRecord & ContactLogRecord::operator=(const ContactLogRecord &other)
{
PH_TRACE;
ContactData::operator=(other);
return *this;
}
}
}
}
|