Newer
Older
#ifndef LIBMOBILE_H
#define LIBMOBILE_H
#include <curl/curl.h>
#include <json-c/json.h>
#include <string.h>
#include <libubox/blobmsg.h>
Jakob Olsson
committed
/**
* Function: write_to_ubus
*
* Prints a json_object pointer's json structure to ubus.
*
* Parameters:
* parsed_response - A struct json_object pointer to json structure to be printed to ubus.
* ctx - Ubus context containing connection.
* req - Information for from the ubus request.
*
* Returns:
* 0 On success.
* -1 On failure.
*/
int write_to_ubus(struct json_object *parsed_response, struct ubus_context *ctx, struct ubus_request_data *req);
Jakob Olsson
committed
/**
* Function: curl_cleaner
*
* Free's the curl environment.
*
* Parameters:
* curl - The curl easy handle variable.
*/
void curl_cleaner(CURLcode *curl);
Jakob Olsson
committed
/**
* Function: write_func
*
* The callback function from performing the curl command, response from server will be parsed here.
*
* Parameters:
* buffer - Contains chunk of response from server.
* size - Size (byte) of type in buffer array.
* nmemb - Number of members in buffer.
* userp - Pointer to area allocated for storing results from server.
*
* Returns:
* Number of bytes managed (size*nmemb).
*/
size_t write_func(void *buffer, size_t size, size_t nmemb, void *userp);
Jakob Olsson
committed
/**
* Function: json_to_blob
*
* Parses a json_object pointer to a corresponding blob buffer.
*
* Parameters:
* response - json_object pointer to be replicated in a blob buffer.
* bb - The blob buffer to hold the results.
*
* Returns:
* Blob buffer containing the replicated json_object.
*/
struct blob_buf json_to_blob(struct json_object *response, struct blob_buf bb);
Jakob Olsson
committed
/**
* Function: apn_profile_idx
*
* Finds the index of a given profile name from all available profiles.
*
* Parameters:
* apn_profiles - json_object pointer to apn_profiles (gotten from a previous call to <mobile_get_apn_profiles>)
* name - Name of the APN index for which will be searched.
*
* Returns:
* Index of the APN on success.
* -1 on failure.
*/
int apn_profile_idx(struct json_object *apn_profiles, char *name);
Jakob Olsson
committed
/**
* Function: get_apn_profiles_len
*
* Finds the number of APN profiles available.
*
* Returns:
* Number of APN profiles available on success.
* -1 on failure.
*/
int get_apn_profiles_len(void);
Jakob Olsson
committed
/**
* Function: mobile_connect_network
*
* Connects the dongle's network.
*
* Returns:
* A string containing the servers response (a json string containing {"result": "success"/"failure"}), indicating whether the call was successful or not.
* NULL on failure.
*/
char *mobile_connect_network(void);
Jakob Olsson
committed
/**
* Function: mobile_disconnect_network
*
* Disconnects the dongle's network.
*
* Returns:
* A string containing the servers response (a json string containing {"result": "success"/"failure"}), indicating whether the call was successful or not.
* NULL on failure.
*/
char *mobile_disconnect_network(void);
Jakob Olsson
committed
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/**
* Function: mobile_delete_apn
*
* Deletes an existing APN profile from the APN list.
*
* Parameters:
* name - The name of the APN profile to be removed.
*
* Returns:
* A string containing the servers response (a json string containing {"result": "success"/"failure"}), indicating whether the call was successful or not.
* NULL on failure.
*/
char *mobile_delete_apn(char *name);
/**
* Function: mobile_enable_roaming
*
* Enables the roaming option on the dongle.
*
* Parameters:
* name - The name of the APN profile to be removed.
*
* Returns:
* A string containing the servers response (a json string containing {"result": "success"/"failure"}), indicating whether the call was successful or not.
* NULL on failure.
*/
char *mobile_enable_roaming(void);
char *mobile_disable_roaming(void);
char *mobile_get_roam_status(void);
char *mobile_get_wan_apn(void);
char *mobile_get_pinnumber(void);
char *mobile_get_pin_status(void);
char *mobile_get_modem_state(void);
char *mobile_get_apn_profiles(void);
char *mobile_create_apn_profile(char *apn);
char *mobile_set_apn_profile(int idx);
char *mobile_enable_pin(char *pin);
char *mobile_set_pin(char *current_pin, char *new_pin);
char *mobile_disable_pin(char *pin);
char *mobile_post_request(char *query);
char *mobile_get_request(char *vars);