- append new input in browse mode
- no need for incremental parsing atm SVN revision: 49161
This commit is contained in:
parent
acba4d96f1
commit
6df1a72435
|
@ -40,12 +40,13 @@ struct _Plugin
|
|||
Evry_Plugin base;
|
||||
Ecore_Timer *timer;
|
||||
|
||||
int browse_mode;
|
||||
|
||||
const char *input;
|
||||
const char *request;
|
||||
const char *host;
|
||||
|
||||
int browse_mode;
|
||||
const char *browse_input;
|
||||
|
||||
int (*fetch) (void *data);
|
||||
int (*data_cb) (Plugin *p, const char *msg, int len);
|
||||
|
||||
|
@ -395,15 +396,14 @@ _web_link_free(Evry_Item *it)
|
|||
E_FREE(wl);
|
||||
}
|
||||
|
||||
static char thumb_buf[4096];
|
||||
|
||||
|
||||
static Evas_Object *
|
||||
_web_link_icon_get(Evry_Item *it, Evas *e)
|
||||
{
|
||||
Web_Link *wl = (Web_Link *) it;
|
||||
Evas_Object *o;
|
||||
|
||||
static char thumb_buf[4096];
|
||||
|
||||
if (!wl->thumb_file)
|
||||
{
|
||||
char *sum = evry->util_md5_sum(wl->thumb);
|
||||
|
@ -532,7 +532,7 @@ _begin(Evry_Plugin *plugin, const Evry_Item *it)
|
|||
|
||||
if (it && CHECK_TYPE(it, EVRY_TYPE_TEXT))
|
||||
{
|
||||
p->input = eina_stringshare_ref(it->label);
|
||||
p->browse_input = eina_stringshare_ref(it->label);
|
||||
p->browse_mode = 1;
|
||||
}
|
||||
|
||||
|
@ -553,6 +553,7 @@ _cleanup(Evry_Plugin *plugin)
|
|||
ecore_timer_del(p->timer);
|
||||
|
||||
IF_RELEASE(p->input);
|
||||
IF_RELEASE(p->browse_input);
|
||||
|
||||
EVRY_PLUGIN_ITEMS_FREE(p);
|
||||
|
||||
|
@ -594,32 +595,44 @@ _fetch(Evry_Plugin *plugin, const char *input)
|
|||
{
|
||||
GET_PLUGIN(p, plugin);
|
||||
|
||||
IF_RELEASE(p->input);
|
||||
|
||||
if (p->timer)
|
||||
{
|
||||
ecore_timer_del(p->timer);
|
||||
p->timer = NULL;
|
||||
}
|
||||
|
||||
if (p->browse_mode)
|
||||
{
|
||||
char buf[128];
|
||||
|
||||
if (p->browse_mode == 1)
|
||||
{
|
||||
p->input = eina_stringshare_ref(p->browse_input);
|
||||
_send_request(p);
|
||||
p->browse_mode = 2;
|
||||
return 1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
IF_RELEASE(p->input);
|
||||
|
||||
if (p->timer)
|
||||
ecore_timer_del(p->timer);
|
||||
p->timer = NULL;
|
||||
|
||||
if (input && strlen(input) >= plugin->config->min_query)
|
||||
else if (input)
|
||||
{
|
||||
p->input = eina_stringshare_add(input);
|
||||
p->timer = ecore_timer_add(0.1, _send_request, p);
|
||||
snprintf(buf, sizeof(buf), "%s %s", p->browse_input, input);
|
||||
p->input = eina_stringshare_add(buf);
|
||||
}
|
||||
else
|
||||
{
|
||||
EVRY_PLUGIN_ITEMS_FREE(p);
|
||||
p->input = eina_stringshare_ref(p->browse_input);
|
||||
}
|
||||
}
|
||||
else if (input && strlen(input) >= plugin->config->min_query)
|
||||
{
|
||||
p->input = eina_stringshare_add(input);
|
||||
}
|
||||
|
||||
if (p->input)
|
||||
p->timer = ecore_timer_add(0.1, _send_request, p);
|
||||
else
|
||||
EVRY_PLUGIN_ITEMS_FREE(p);
|
||||
|
||||
return !!(p->base.items);
|
||||
}
|
||||
|
@ -1691,6 +1704,7 @@ _json_parse(const char *string, int len)
|
|||
{
|
||||
struct json_parser parser;
|
||||
int i, ret;
|
||||
Json_Data *d;
|
||||
|
||||
if (!string)
|
||||
return NULL;
|
||||
|
@ -1698,7 +1712,7 @@ _json_parse(const char *string, int len)
|
|||
if (!len)
|
||||
len = strlen(string);
|
||||
|
||||
Json_Data *d = E_NEW(Json_Data, 1);
|
||||
d = E_NEW(Json_Data, 1);
|
||||
d->cur = d;
|
||||
|
||||
if (json_parser_init(&parser, NULL, _parse_callback, d))
|
||||
|
@ -1708,31 +1722,14 @@ _json_parse(const char *string, int len)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
for (i = 0; i < len; i += 1)
|
||||
{
|
||||
if ((ret = json_parser_string(&parser, string + i, 1, NULL)))
|
||||
{
|
||||
if (d->cur == d)
|
||||
{
|
||||
ret = 0;
|
||||
break;
|
||||
|
||||
}
|
||||
else
|
||||
if ((ret = json_parser_string(&parser, string, len, NULL)) && !(d->cur == d))
|
||||
{
|
||||
ERR("%d\n", ret);
|
||||
break;
|
||||
}
|
||||
}
|
||||
_json_data_free(d);
|
||||
d = NULL;
|
||||
}
|
||||
|
||||
json_parser_free(&parser);
|
||||
if (ret)
|
||||
{
|
||||
_json_data_free(d);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return d;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue