언어 설정

Menu
Sites
Language
Error Code: -22 [ APP_CONTROL_ERROR_INVALID_PARAMETER ] Need A Path Of Selected File, Thanks Dinal Jivani
static void
file_select_result(app_control_h request, app_control_h handle, app_control_result_e result, void *user_data)
{
char *value=NULL;
    int ret;

    if (result == APP_CONTROL_RESULT_SUCCEEDED)
    {
    //app_control_add_extra_data(handle,"path",value);

    char keyId[100] = {0, };

    ret=app_control_get_extra_data(handle, keyId,&value);
        if (ret == APP_CONTROL_ERROR_NONE)
        {
            dlog_print(DLOG_INFO, LOG_TAG, "[app_control_result_cb]Succeeded : Error code - %d || Path - %s",ret,value);
        }
        else
        {
           dlog_print(DLOG_ERROR, LOG_TAG, "[app_control_result_cb]Failed : Error code - %d || Path - %s",ret,value);
        }
    }
    else
    {
        dlog_print(DLOG_ERROR, LOG_TAG, "[app_control_result_cb] APP_CONTROL_RESULT_FAILED. Error code: %d", result);
    }
}
static void
btn_file_select_cb(void *data, Evas_Object *obj, void *event_info)
{
app_control_h app_control;
int ret;

app_control_create(&app_control);
app_control_set_operation(app_control, APP_CONTROL_OPERATION_PICK);
app_control_set_mime(app_control, "image/*");

ret = app_control_send_launch_request(app_control, file_select_result, NULL);
if ( ret == APP_CONTROL_ERROR_NONE)
{
  dlog_print(DLOG_INFO, LOG_TAG, "Succeeded to launch a file manager picker app.");
}
else
{
  dlog_print(DLOG_ERROR, LOG_TAG, "Failed to launch a file manager picker app. error code: %d", ret);
}

app_control_destroy(app_control);
}

I Need A Path Of Selected File From The App Control....

Edited by: Dinal Jivani on 15 9월, 2017
답변 바로가기

Responses

16 댓글
bhoomika rathod

i got the error -126 in my code. 

Here is my code.

static void
file_select_result(app_control_h request, app_control_h reply, app_control_result_e result, void *user_data)
{
char *value;
   int ret;

   if (result == APP_CONTROL_RESULT_SUCCEEDED)
   {
    ret=app_control_get_extra_data(reply, APP_CONTROL_DATA_PATH, &value);
       if ( ret == APP_CONTROL_ERROR_NONE)
       {
           dlog_print(DLOG_INFO, LOG_TAG, " [app_control_result_cb] Succeeded: value(%s)", value);
       }
       else
       {
           dlog_print(DLOG_ERROR, LOG_TAG, " [app_control_result_cb] Failed, Error code: %d",ret);
       }
       //app_control_foreach_extra_data(reply, foreach_extra_data_cb, NULL);
   }
   else
   {
       dlog_print(DLOG_ERROR, LOG_TAG, " [app_control_result_cb] APP_CONTROL_RESULT_FAILED. Error code: %d", result);
}
 
static void
btn_file_select_cb(void *data, Evas_Object *obj, void *event_info)
{
app_control_h app_control;
int ret;
 
app_control_create(&app_control);
app_control_set_operation(app_control, APP_CONTROL_OPERATION_PICK);
app_control_set_mime(app_control, "image/*"); // or, app_control_set_mime(app_control, "*/*");
 
ret = app_control_send_launch_request(app_control, file_select_result, NULL);
 
if ( ret == APP_CONTROL_ERROR_NONE)
{
  dlog_print(DLOG_INFO, LOG_TAG, " Succeeded to launch a file manager picker app.");
}
 
else
{
  dlog_print(DLOG_ERROR, LOG_TAG, " Failed to launch a file manager picker app. error code: %d", ret);
}
 
app_control_destroy(app_control);
}
 
 
 
dlog:
Succeeded to launch a file manager picker app.
[app_control_result_cb] Failed, Error code: -126
Armaan-Ul- Islam

You have used different variable names for the 'Reply App Control handle'.

Initialized the 'Reply App Control handle' as 'handle'

But Inside the callback function you have used the name 'reply'  for the 'Reply App Control handle'.

 

static void
file_select_result(app_control_h request, app_control_h ****handle****, app_control_result_e result, void *user_data)
{
char *value=NULL;
    int ret;
 
    if (result == APP_CONTROL_RESULT_SUCCEEDED)
    {
    //app_control_add_extra_data(handle,"path",value);
 
    char keyId[100] = {0, };
 
    ret=app_control_get_extra_data(****reply*****, keyId, &value);

 

Should Change the line 2 like:

file_select_result(app_control_h request, app_control_h reply, app_control_result_e result, void *user_data)

 

 

And for further documentations:

app_control_send_launch_request

app_control_reply_cb

 

Dinal Jivani

Still getting the same Error : -22

Armaan-Ul- Islam

Error 22 Means: APP_CONTROL_ERROR_INVALID_PARAMETER

 

To Get the Error list: (Cntrl+Right click) on  APP_CONTROL_ERROR_NONE

That would take you to app_control.h file, You can find the meaning of Error codes there.From Error list on app_control.h , Mark an Error > press F2 to focus.

 

You are giving Invalid parameter to the function app_control_get_extra_data()

 

 

Dinal Jivani

I need a Solution to this Issue , I'd already seen the Error Defined in the Header File.

Armaan-Ul- Islam

App control extra data is a key value pair data type. <key,value>

 

Once you add an extra data value for a key using app_control_add_extra_data()

Then, You can retrieve the value of that key using app_control_get_extra_data()

 

By the way,

char keyId[10] ={0, }

Initialization is not working here for some reason, You have to init with a hardcoded string.

You may try replacing this code snippet inside your code:

 


char keyId[10] = "keyA";     // or char *keyId = "keyA";
char *valueIn="valueABC";

app_control_add_extra_data(reply,keyId,valueIn);    //add data

ret=app_control_get_extra_data(reply,keyId,&valueOut);  //get data

    if (ret == APP_CONTROL_ERROR_NONE)
    {
        dlog_print(DLOG_INFO, LOG_TAG, "[app_control_result_cb]Succeeded : Error code - %d || Path - %s key -%s",ret,valueOut,keyId);
    }
    else
    {
        dlog_print(DLOG_ERROR, LOG_TAG, "[app_control_result_cb]Failed : Error code - %d || Path - %skey -%s",ret,valueOut,keyId);
    }

}

 

Dinal Jivani

it goes to the success part with the following Log

 

Dlog:

[app_control_result_cb]Succeeded : Error code - 0 || Path - valueABC key -keyA
Armaan-Ul- Islam

That's it !!!

 

This is the purpose of 'App control extra data'. Add data is the setter method and get data is the getter method.

Error code 0 means APP_CONTROL_ERROR_NONE. The app_control_get_extra_data() function got the extra data specified by the key successfully.

 

I just copied your dlog_print line.

 

 

Dinal Jivani

the Path of Image is what i want...i am not getting the path of the selected Image in the Path .

 

The Code you given must return the path of selected image from the file Picker but it is not returning.....

it Returns :

[app_control_result_cb]Succeeded : Error code - 0 || Path - valueABC key -keyA

And , in My code it Gives some Garbage Value.

Mark as answer
Armaan-Ul- Islam

APP_CONTROL_DATA_SELECTED is the key to get the path of a resource.

 

And as the return type would be an array, you have to use app_control_get_extra_data_array() instead of app_control_get_extra_data().

 

char **valueOut;
int ret;

if (result == APP_CONTROL_RESULT_SUCCEEDED)
{
    
	int len;

    ret=app_control_get_extra_data_array(reply, APP_CONTROL_DATA_SELECTED ,&valueOut,&len);
        
    if (ret == APP_CONTROL_ERROR_NONE)
    {
        dlog_print(DLOG_INFO, LOG_TAG, "[app_control_result_cb]Succeeded : Error code - %d || Path - %s ",ret,*valueOut);
    }
    else
    {
       dlog_print(DLOG_ERROR, LOG_TAG, "[app_control_result_cb]Failed : Error code - %d || Path - %s",ret,*valueOut,);
    }

 

Please 'Mark as answer' to promote this response to other developers stuck on the same scenario. For further documentation:

app_control_get_extra_data_array

Dinal Jivani

Thanks Alot Armaan-Ul- Islam I Got It :D 

bhoomika rathod

How can i store this path which is in char** into string format.

Dinal Jivani

i need some more help please....

 

How can I store ValueOut (path of selected file) in string (i.e. : Char * , Const Char *) format ?

 

 

Armaan-Ul- Islam

Sure.

We can say char ** valueOut is an array of char* in a sence. In the code above there is an integer 'len' declared. In app_control_get_extra_data_array() function, the fourth parameter is the pointer to the length of the array on third parameter, in our case valueOut.

 

So, len refers to the length of array of string 'valueOut'. You can try simple iteration to get the string.

int len;

ret=app_control_get_extra_data_array(reply, APP_CONTROL_DATA_SELECTED ,&valueOut,&len);

for(int i=0; i<len; i++)
    dlog_print(DLOG_INFO, LOG_TAG, "PATH: %s", valueOut[i]);
bhoomika rathod

Actually, i tried this solution.But i want to store this path in string.
for example,

char path[PATH_MAX];

...

for(int i=0; i<len; i++)
     sprintf(path,"%s",valueOut[i]);
     dlog_print(DLOG_INFO, LOG_TAG, "IMAGE PATH: %s",path);
 
Dinal Jivani

Declaration :

char *path;

Then the initialization :

for(int i=0; i<len; i++)
{
     path=valueOut[i];
	 dlog_print(DLOG_INFO, LOG_TAG, "Dinal PATH----> %s",path);
}

:D