void callback_system_get_info_callback(void *arg, rho::String const &strQuery) { rho::String responce = make_info_string(true); rho_http_sendresponse(arg, responce.c_str()); }
void callback_system_update_bundle_callback(void *arg, rho::String const &strQuery) { const char* s = strQuery.c_str(); // status ok,error,need_sync // message "bla bla bla" rho::String qStatus = ""; rho::String qMessage = ""; rho::common::CTokenizer oTokenizer(strQuery, "&"); while (oTokenizer.hasMoreTokens()) { rho::String tok = oTokenizer.nextToken(); if (tok.length() == 0) continue; if ( rho::String_startsWith(tok, "status=") ) { qStatus = tok.substr(7); }else if ( rho::String_startsWith( tok, "message=") ) { qMessage = tok.substr(8); } } rho::String query = ""; bool our_refresh_webview = false; rho::String our_responce_server_url = ""; BundleUpdateThreadQueue::BUCommand* cmd = getBundleUpdateThreadQueueSignletone()->getCurrentBUCommand(); if (cmd != NULL) { our_refresh_webview = cmd->refresh_webview; our_responce_server_url = cmd->responce_url; } rho::String message = "Unrecognizing Situation during update bundle! Restart application and reconnect device to server !"; if (qStatus.compare("ok") == 0) { message = "Update bundle was finished !"; query = "&status=ok"; if (our_refresh_webview) { rho_webview_refresh(-1); } } if (qStatus.compare("error") == 0) { message = "Error when update Bundle : " + qMessage + " !"; query = "&status=error&message="+message; } if (qStatus.compare("need_sync") == 0) { message = "Your application files too old. Request for full Bundle update was sended to server !"; query = "&status=need_full_update"; } alert_show_status("Development Extras", message.c_str(), "OK"); //alert_show_popup(&p); rho_http_sendresponse(arg, ""); // send responce to server char* norm_url = rho_http_normalizeurl(our_responce_server_url.c_str()); query = query + make_info_string(false); rho_net_request_with_data_in_separated_thread(norm_url, query.c_str()); rho_http_free(norm_url); // remove temporary files rho::String fileZipLocalDir = rho::common::CFilePath::join(RHODESAPPBASE().getRhoUserPath(), "RhoBundle"); //rho_file_impl_delete_folder(fileZipLocalDir.c_str()); rho::common::CRhoFile::deleteFolder(fileZipLocalDir.c_str()); if (cmd != NULL) { cmd->canContinue = true; } }
int bbus_parse_args(int argc, char** argv, const struct bbus_opt_list* optlist, struct bbus_nonopts** nonopts) { char* shortopts = NULL; struct option* longopts = NULL; const struct bbus_option* curopt = NULL; int opt; int ind = 0; int ret = BBUS_ARGS_GOOD; int flag; char* info = NULL; unsigned i; info = make_info_string(optlist); if (info == NULL) goto out_of_memory; shortopts = make_shortopts(optlist); if (shortopts == NULL) goto out_of_memory; longopts = make_longopts(optlist, &flag); if (longopts == NULL) goto out_of_memory; while ((opt = getopt_long(argc, argv, shortopts, longopts, &ind)) != -1) { switch (opt) { case '?': case ':': fprintf(stderr, "try %s --help\n", argv[0]); ret = BBUS_ARGS_ERR; goto out; break; case 0: /* Long option. */ if (flag < 0) { if (flag == OPT_VERSION) { fprintf(stdout, "%s %s\n", optlist->progname, optlist->version); } else { fprintf(stdout, "%s", info); } ret = BBUS_ARGS_HELP; goto out; } else { curopt = &optlist->opts[flag]; } break; default: /* * Short option. * * FIXME Probably should find a better way to find * the corresponding structure. */ for (i = 0; i < optlist->numopts; ++i) { if (optlist->opts[i].shortopt != 0) { if (optlist->opts[i].shortopt == opt) { curopt = &optlist->opts[i]; } } } break; } /* Now actually handle the option. */ handle_option(curopt->action, curopt->actdata, optarg); } for (i = 0; i < optlist->numpargs; ++i) { if (optind >= argc) { fprintf(stderr, "%s: expected additional parameters" "\ntry %s --help\n", argv[0], argv[0]); ret = BBUS_ARGS_ERR; goto out; } handle_option(optlist->pargs[i].action, optlist->pargs[i].actdata, argv[optind]); ++optind; } if (nonopts != NULL) { *nonopts = find_nonopts(argc, argv); if (*nonopts == NULL) goto out_of_memory; } goto out; out_of_memory: fprintf(stderr, "%s: %s\n", __FUNCTION__, bbus_strerror(BBUS_ENOMEM)); ret = BBUS_ARGS_ERR; out: bbus_free(shortopts); bbus_free(longopts); bbus_free(info); return ret; }