int _ctx_history_query(const char* uri, const char* filter, ctx_history_cursor_h* cursor);
+int ctx_history_is_supported(const char* uri, bool* supported);
+
/* Cursor */
int ctx_history_cursor_destroy(ctx_history_cursor_h cursor);
return E_SUPPORT;
}
+EXPORT_API int ctx_history_is_supported(const char* uri, bool* supported)
+{
+ return E_SUPPORT;
+}
+
EXPORT_API int ctx_history_cursor_destroy(ctx_history_cursor_h cursor)
{
return E_SUPPORT;
using namespace ctx;
+static ServiceProxy* __getServiceProxy()
+{
+ static ServiceProxy proxy(CTX_APP_HISTORY);
+ return &proxy;
+}
+
EXPORT_API int ctx_history_query(const char* uri, int64_t start_time, int64_t end_time, unsigned int result_size, ctx_history_cursor_h* cursor)
{
Json filter;
{
IF_FAIL_RETURN(uri && cursor, E_PARAM);
- ServiceProxy proxy(CTX_APP_HISTORY);
-
GVariant* output = NULL;
- int err = proxy.call("readJson", g_variant_new("(ss)", uri, filter), &output);
+ int err = __getServiceProxy()->call("readJson", g_variant_new("(ss)", uri, filter), &output);
IF_FAIL_RETURN_TAG(err == E_NONE, err, _E, "%s", CTX_ERROR_STR(err));
char* columnNames = NULL;
return err;
}
+EXPORT_API int ctx_history_is_supported(const char* uri, bool* supported)
+{
+ IF_FAIL_RETURN(uri, E_PARAM);
+
+ *supported = false;
+
+ int err = __getServiceProxy()->call("isSupported", g_variant_new("(s)", uri));
+ if (err == E_NONE)
+ *supported = true;
+
+ if (err == E_SUPPORT)
+ return E_NONE;
+
+ return err;
+}
+
EXPORT_API int ctx_history_cursor_destroy(ctx_history_cursor_h cursor)
{
IF_FAIL_RETURN(cursor, E_NONE);
int64_t val;
IF_FAIL_RETURN_TAG(cursor->tuples[cursor->index]->getAt(idx, &val), E_PARAM, _E, "Invalid data");
- //TODO: Type checking & locale-invariant?
*value = val;
return E_NONE;
double val;
IF_FAIL_RETURN_TAG(cursor->tuples[cursor->index]->getAt(idx, &val), E_PARAM, _E, "Invalid data");
- //TODO: Type checking & locale-invariant?
*value = val;
return E_NONE;
throw static_cast<int>(E_PARAM);
}
+ /* Check history data supported */
+ StatsProvider* provider = StatsManager::getProvider(subject);
+ if (!provider) {
+ throw static_cast<int>(E_SUPPORT);
+ } else if (!provider->isSupported()) {
+ throw static_cast<int>(E_SUPPORT);
+ }
+
+ /* Process method call */
if (methodCall->getMethodName() == "readJson") {
- __readJson(StatsManager::getProvider(subject), methodCall);
+ __readJson(provider, methodCall);
+ } else if (methodCall->getMethodName() == "isSupported") {
+ methodCall->reply(E_NONE);
}
} catch (int error) {
methodCall->reply(error);
void AppHistoryClient::__readJson(StatsProvider* provider, MethodCall* methodCall)
{
- if (!provider)
- throw static_cast<int>(E_SUPPORT);
-
if (!provider->isAllowed(*this))
throw static_cast<int>(E_ACCESS);
return __subject;
}
-int StatsProvider::isSupported(void)
+bool StatsProvider::isSupported(void)
{
- return E_NONE;
+ return true;
}
bool StatsProvider::isAllowed(AppHistoryClient& client)
std::string& getSubject(void);
- virtual int isSupported(void);
+ virtual bool isSupported(void);
virtual bool isAllowed(AppHistoryClient& clieint);
virtual std::string getQuery(Json& filter);
" <arg type='s' name='columnNames' direction='out'/>" \
" <arg type='v' name='result' direction='out'/>" \
"</method>" \
+ "<method name='isSupported'>" \
+ " <arg type='s' name='uri' direction='in'/>" \
+ "</method>" \
"<method name='getLastFullyChargedTime'>" \
" <arg type='i' name='result' direction='out'/>" \
"</method>"