Esempio n. 1
0
int
ios_icon_imagedata(lua_State* L)
{
  char* pngdata;
  uint64_t pngsize;
  int rc;

  if (lua_isnoneornil(L, -1)) { luaL_error(L, "missing icon reference"); }

  lua_getfield(L, -1, kAppleBundleIdKey);
  const char* bundleID = luaL_checkstring(L, -1);
  lua_pop(L, 1);
  lua_pop(L, 1);

  SBConnection* c = popConnection(L);
  lua_pop(L, 1);

  // fprintf(stderr, "loading icon for %s, using %p\n", bundleID, c);
  if ((rc = sbservices_get_icon_pngdata(c->sbClient, 
                                        bundleID, 
                                        &pngdata, 
                                        &pngsize)) 
        != SBSERVICES_E_SUCCESS) { luaL_error(L, "error %d fetching"
                                                 " image", rc); }

  lua_pushlstring(L, pngdata, pngsize);
  free(pngdata);

  return 1;
}
Esempio n. 2
0
DeviceStatus Device::getIcon(string appId, string path) {
    if (this->mSb == NULL) {
        if (sbservices_client_start_service(this->mDevice, &this->mSb, NULL) != SBSERVICES_E_SUCCESS) {
            return StatusError;
        }
    }
    char *buffer = NULL;
    uint64_t length = 0;
    if (sbservices_get_icon_pngdata(this->mSb, appId.c_str(), &buffer, &length) != SBSERVICES_E_SUCCESS) {
        return StatusError;
    }
    if (createLocalFile(path, buffer, (int)length) != 0) {
        free(buffer);
        return StatusError;
    }
    free(buffer);
    return StatusOK;
}
Esempio n. 3
0
FB::variant ibrowserAPI::getSbservicesIconPngdata(const std::string& bundleId,F_ADD)
{
    THREAD(&ibrowserAPI::getSbservicesIconPngdata, bundleId);
    
    if(bundleId.empty())
        return NULL;
    char *data = NULL;
    uint64_t size = 0;
    if (SBSERVICES_E_SUCCESS != sbservices_get_icon_pngdata(sbservices_client,bundleId.c_str(),&data,&size))
    {
        ERRO("get_sbservices_icon_pngdata error");
    }
    char *base64 = base64encode(data,size);
    free(data);
    
    SUCC(base64);
    
    return base64;
    
}