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
|
/*
* Contacts Service
*
* Copyright (c) 2010 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact: Youngjae Shin <yj99.shin@samsung.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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 <fcntl.h>
#include <unistd.h>
#include "contacts.h"
#include "ctsvc_internal.h"
#include "ctsvc_sqlite.h"
#include "ctsvc_schema.h"
static const char *CTS_RESTRICTION_CHECK_FILE="/opt/usr/data/contacts-svc/.CONTACTS_SVC_RESTRICTION_CHECK";
static TLS int ctsvc_restriction_permit;
int ctsvc_restriction_init(void)
{
if (!ctsvc_restriction_permit) {
int fd = open(CTS_RESTRICTION_CHECK_FILE, O_RDONLY);
if (0 <= fd) {
close(fd);
ctsvc_restriction_permit = TRUE;
} else {
CTS_ERR("Restriction Mode");
}
}
if (!ctsvc_restriction_permit) {
int ret;
const char *query;
query = "CREATE TEMP VIEW "CTS_TABLE_RESTRICTED_DATA_VIEW" AS SELECT * FROM "CTS_TABLE_DATA" WHERE is_restricted != 1 AND is_my_profile = 0";
ret = ctsvc_query_exec(query);
RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "cts_query_exec() Failed(%d)", ret);
}
return CONTACTS_ERROR_NONE;
}
void ctsvc_restriction_deinit(void)
{
ctsvc_restriction_permit = FALSE;
}
int ctsvc_restriction_get_permit(void)
{
return ctsvc_restriction_permit;
}
#if 0
/**
* This function make restricted contact.
* If process does not have permission for restriction, this function will be failed.
*
* @param[in] contact The contacts service struct
* @return #CTS_SUCCESS on success, Negative value(#cts_error) on error
*/
API int contacts_svc_struct_set_restriction(CTSstruct *contact)
{
contact_t *record = (contact_t *)contact;
RETV_IF(NULL == contact, CTS_ERR_ARG_NULL);
RETV_IF(FALSE == ctsvc_restriction_permit, CTS_ERR_ENV_INVALID);
record->is_restricted = TRUE;
return CONTACTS_ERROR_NONE;
}
#endif
|