}
EXPORT
-int tmonitor_init(int period, int (*func)(void *data, void* user_data), void *user_data)
+int tmonitor_init(void)
{
struct tmonitor_client *client;
struct sockaddr_in server_addr;
return -ENOMEM;
}
- /* the minimum period is 100ms */
- if (period > 0 || period < 100)
- period = 100;
-
- client->period = period;
- client->func = func;
- client->user_data = user_data;
-
/* open socket to server */
client->id = socket(AF_INET, SOCK_STREAM, 0);
if (client->id < 0) {
}
EXPORT
-int tmonitor_connect(void)
-{
- return tmonitor_init(0, NULL, NULL);
-}
-
-EXPORT
int tmonitor_exit(int id)
{
struct tmonitor_client *client;
}
EXPORT
+int tmonitor_get_resource_count(int id, int resource_type)
+{
+ return 0;
+}
+
+EXPORT
int tmonitor_create_resource(int id, int resource_type)
{
char buffer[MAX_BUF_SIZE + 1];
}
EXPORT
-int tmonitor_set_attr_interest(int id, int resource_id, u_int64_t attr_mask)
+int tmonitor_delete_resource(int id, int resource_id)
+{
+ return 0;
+}
+
+EXPORT
+int tmonitor_set_resource_ctrl(int id, int resource_id, u_int64_t ctrl_id, int value)
{
char buffer[MAX_BUF_SIZE + 1];
int buffer_len;
int response_req;
int ret;
- buffer_len = sprintf(buffer, "%d:%d:%"PRIu64,
- REQUEST_SET_ATTR_INTEREST, resource_id, attr_mask);
+ buffer_len = sprintf(buffer, "%d:%d:%"PRIu64":%d",
+ REQUEST_SET_RESOURCE_CTRL, resource_id, ctrl_id, value);
if (send(id, buffer, buffer_len, 0) < 0) {
_E("[libpass] error occurred while sending buffer");
return -EIO;
if (sscanf(buffer, "%d:%d", &response_req, &ret) < 2)
return -EINVAL;
- if (response_req != REQUEST_SET_ATTR_INTEREST) {
+ if (response_req != REQUEST_SET_RESOURCE_CTRL) {
_E("[libpass] wrong response");
return -EINVAL;
}
}
EXPORT
-int tmonitor_set_resource_control(int id, int resource_id, u_int64_t ctrl_id, int value)
+int tmonitor_set_resource_attr(int id, int resource_id, u_int64_t attr_mask)
{
char buffer[MAX_BUF_SIZE + 1];
int buffer_len;
int response_req;
int ret;
- buffer_len = sprintf(buffer, "%d:%d:%"PRIu64":%d",
- REQUEST_SET_RESOURCE_CONTROL, resource_id, ctrl_id, value);
+ buffer_len = sprintf(buffer, "%d:%d:%"PRIu64,
+ REQUEST_SET_RESOURCE_ATTR, resource_id, attr_mask);
if (send(id, buffer, buffer_len, 0) < 0) {
_E("[libpass] error occurred while sending buffer");
return -EIO;
if (sscanf(buffer, "%d:%d", &response_req, &ret) < 2)
return -EINVAL;
- if (response_req != REQUEST_SET_RESOURCE_CONTROL) {
+ if (response_req != REQUEST_SET_RESOURCE_ATTR) {
_E("[libpass] wrong response");
return -EINVAL;
}
return ret;
}
-EXPORT
-int tmonitor_get_available_attrs(int id, int resource_type,
- int *available_attrs[], int *num_attrs)
-{
- /* TODO */
- return 0;
-}
EXPORT
-int tmonitor_start(int id)
+int tmonitor_unset_resource_attr(int id, int resource_id, u_int64_t attr_mask)
{
return 0;
}
EXPORT
-int tmonitor_stop(int id)
+bool tmonitor_is_resource_attr_supported(int id, int resource_id, u_int64_t attr_id)
{
return 0;
}
return ret;
}
-
-
-EXPORT
-int tmonitor_get_resource_num(int id, int resource_type)
-{
- return 0;
-}
#ifndef __TMONITOR__
#define __TMONITOR__
+#include <stdio.h>
+#include <stdbool.h>
+
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Initialize the tizen monitor
- * @param[in] Timer period (unit: millisecond, minimum value is 100ms)
- * @param[in] Timer callback function
- * @param[in] User data be passed to timer callback function
- * @return @c positive integer on success, otherwise a negative error value
+ * @return @c positive integer as tizen monitor id on success, otherwise a negative error value
*/
-int tmonitor_init(int period, int (*func)(void *data, void* user_data), void *user_data);
-
-/**
- * @brief Initialize the tizen monitor quickly
- * @return @c positive integer on success, otherwise a negative error value
- */
-int tmonitor_connect(void);
+int tmonitor_init(void);
/**
* @brief Exit the tizem monitor
- * @param[in] Unique id of tizen monitor which be returnted by tmonitor_init
+ * @param[in] Id of tizen monitor which be returnted by tmonitor_init
* @return @c 0 on success, otherwise a negative error value
*/
int tmonitor_exit(int id);
/**
- * @brief Alias of tmonitor_exit to provide pair with tmonitor_connect
- * @param[in] Unique id of tizen monitor which be returnted by tmonitor_connect
- * @return @c 0 on success, otherwise a negative error value
+ * @brief Get the count of supported resources according to resource type
+ * @param[in] Tizen monitor id
+ * @param[in] Resource type
+ * @return @c positive integer as resource count on success, otherwise a negative error value
*/
-#define tmonitor_disconnect tmonitor_exit
+int tmonitor_get_resource_count(int id, int resource_type);
/**
* @brief Create resource for given resource_type
- * @param[in] Unique id of tizen monitor which be returnted by tmonitor_init/connect
+ * @param[in] Tizen monitor id which be returnted by tmonitor_init
* @param[in] Resource type
- * @return @c positive integer as resource handler id on success, otherwise a negative error value
+ * @return @c positive integer as resource id on success, otherwise a negative error value
*/
int tmonitor_create_resource(int id, int resource_type);
/**
- * @brief Set the interested attributes for monitoring
- * @param[in] Unique id of tizen monitor
- * @param[in] Unique id of resource
- * @param[in] Attribute mask including the various attributes
+ * @brief Delete resource of given resource id
+ * @param[in] Tizen monitor id which be returnted by tmonitor_init
+ * @param[in] Resource id
* @return @c 0 on success, otherwise a negative error value
*/
-int tmonitor_set_attr_interest(int id, int resource_id, u_int64_t attr_mask);
+int tmonitor_delete_resource(int id, int resource_id);
+
+/**
+ * @brief Set the resource control with value which is diffierential according to resource control id
+ * @param[in] Tizen monitor id
+ * @param[in] Resource id
+ * @param[in] Resource control id
+ * @param[in] Value for resource control id
+ * @return @c 0 on success, otherwise a negative error value
+ */
+int tmonitor_set_resource_ctrl(int id, int resource_id, u_int64_t ctrl_id, int value);
/**
* @brief Set the interested attributes for monitoring
- * @param[in] Unique id of tizen monitor
- * @param[in] Unique id of resource
+ * @param[in] Tizen monitor id
+ * @param[in] Resource id
* @param[in] Attribute mask including the various attributes
* @return @c 0 on success, otherwise a negative error value
*/
-int tmonitor_set_resource_control(int id, int resource_id, u_int64_t ctrl_id, int value);
+int tmonitor_set_resource_attr(int id, int resource_id, u_int64_t attr_mask);
/**
- * @brief Start tizen monitor with asynchronous method
- * @param[in] Unique id of tizen monitor
+ * @brief Unset the interested attributes for monitoring
+ * @param[in] Tizen monitor id
+ * @param[in] Resource id
+ * @param[in] Attribute mask including the various attributes
* @return @c 0 on success, otherwise a negative error value
*/
-int tmonitor_start(int id);
+int tmonitor_unset_resource_attr(int id, int resource_id, u_int64_t attr_mask);
/**
- * @brief Stop tizen monitor
- * @param[in] Unique id of tizen monitor
+ * @brief Check whether a resouce attribute is supported or not
+ * @param[in] Tizen monitor id
+ * @param[in] Resource id
+ * @param[in] Resource attribute id
* @return @c 0 on success, otherwise a negative error value
*/
-int tmonitor_stop(int id);
+bool tmonitor_is_resource_attr_supported(int id, int resource_id, u_int64_t attr_id);
/**
- * @brief Update value of the interested attributes by tmonitor_set_attrs()
- * @param[in] Unique id of tizen monitor
+ * @brief Update value of the interested attributes for all created resource
+ * @param[in] Tizen monitor id
* @return @c 0 on success, otherwise a negative error value
*/
int tmonitor_update(int id);
/**
- * @brief Update value of the interested attributes by tmonitor_set_attrs()
- * @param[in] Unique id of tizen monitor
- * @param[in] Unique id of resource
+ * @brief Update value of the interested attributes for a resource
+ * @param[in] Tizen monitor id
+ * @param[in] Resource id
* @return @c 0 on success, otherwise a negative error value
*/
int tmonitor_update_resource(int id, int resource_id);
/**
* @brief Get [int/int64/uint/uint64/double/string] value of resource attribute
- * @param[in] Unique id of tizen monitor
- * @param[in] Unique id of resource
- * @param[in] Resoruce attribute id
+ * @param[in] Tizen monitor id
+ * @param[in] Resource id
+ * @param[in] Resource attribute id
* @param[out] Value retrieved from resource attribute
* @return @ 0 on success, otherwise a negative error value
*/
int tmonitor_get_value_double(int id, int resource_id, u_int64_t attr, double *value);
int tmonitor_get_value_string(int id, int resource_id, u_int64_t attr, char *value);
-/**
- * @brief Get the supported resource number
- * @param[in] Unique id of tizen monitor
- * @param[in] Resource type
- * @return @c positive integer value, otherwise a negative error value
- */
-int tmonitor_get_resource_num(int id, int resource_type);
-
#ifdef __cplusplus
}
#endif
return update_resource_attrs(res);
}
-static int handle_request_set_attr_interest(struct request_client *client, char *args)
+static int handle_request_set_resource_attr(struct request_client *client, char *args)
{
struct resource *res;
int resource_id;
return -ENOENT;
/**
- * Format of REQUEST_SET_ATTR_INTEREST args:
+ * Format of REQUEST_SET_RESOURCE_ATTR args:
* - <RESOURCE_ID:INTEREST_MASK>
*/
if (sscanf(args, "%d:%"PRIu64, &resource_id, &interest_masks) < 2)
return 0;
}
-static int handle_request_set_resource_control(struct request_client *client, char *args)
+static int handle_request_set_resource_ctrl(struct request_client *client, char *args)
{
struct resource *res;
int resource_id, value;
return -ENOENT;
/**
- * Format of REQUEST_SET_RESOURCE_CONTROL args:
+ * Format of REQUEST_SET_RESOURCE_CTRL args:
* - <RESOURCE_ID:CONTROL_ID:CONTROL_VALUE>
*/
if (sscanf(args, "%d:%"PRIu64":%d", &resource_id, &ctrl_id, &value) < 3)
if (ret < 0)
_D("failed to update resource");
break;
- case REQUEST_SET_ATTR_INTEREST:
- ret = handle_request_set_attr_interest(client, args);
+ case REQUEST_SET_RESOURCE_CTRL:
+ ret = handle_request_set_resource_ctrl(client, args);
if (ret < 0)
- _D("failed to set attr interest");
+ _D("failed to set resource control");
break;
- case REQUEST_SET_RESOURCE_CONTROL:
- ret = handle_request_set_resource_control(client, args);
+ case REQUEST_SET_RESOURCE_ATTR:
+ ret = handle_request_set_resource_attr(client, args);
if (ret < 0)
- _D("failed to set resource control");
+ _D("failed to set attr interest");
break;
case REQUEST_GET_VALUE_INT:
{