int ServerPic::Install(int argc, char *argv[]) { string configUrl("http://192.168.89.1/Test/config.json"); // init error ErrorInfo::Init(); /* // check params count if (argc < 2) return INVALID_ARGV_NUMBERS; // load argv string configUrl(argv[1]); */ // init libcurl curl_global_init(CURL_GLOBAL_ALL); // init system config HttpRequest *configReq = new HttpRequestGet(configUrl); configReq->contentType = HttpContentType::Json; configReq->Connect(); if (configReq->text.empty()) return EMPTY_CONFIG_FILE; AppSetting *setting = AppSetting::Instance(); JsonObject *jsonObj = new JsonObject(); jsonObj->LoadFromText(configReq->text); setting->Load(jsonObj); // Release install memory safe_del(jsonObj); safe_del(configReq); return NO_ERROR; }
bool AvatarManager::remove(Kopete::AvatarManager::AvatarEntry entryToRemove) { // We need name and path to remove an avatar from the storage. if( entryToRemove.name.isEmpty() && entryToRemove.path.isEmpty() ) return false; // We don't allow removing avatars from Contact category if( entryToRemove.category & Kopete::AvatarManager::Contact ) return false; // Delete the image file first, file delete is more likely to fail than config group remove. if( KIO::NetAccess::del(KUrl(entryToRemove.path),0) ) { kDebug(14010) << "Removing avatar from config."; KUrl configUrl(d->baseDir); configUrl.addPath( UserDir ); configUrl.addPath( AvatarConfig ); KConfigGroup avatarConfig ( KSharedConfig::openConfig( configUrl.toLocalFile(), KConfig::SimpleConfig ), entryToRemove.name ); avatarConfig.deleteGroup(); avatarConfig.sync(); emit avatarRemoved(entryToRemove); return true; } return false; }
bool AvatarManager::exists(const QString &avatarName) { KUrl configUrl(d->baseDir); configUrl.addPath( UserDir ); configUrl.addPath( AvatarConfig ); KConfigGroup avatarConfig ( KSharedConfig::openConfig( configUrl.toLocalFile(), KConfig::SimpleConfig ), avatarName ); kDebug(14010) << "Checking if an avatar exists: " << avatarName; if(!avatarConfig.exists()){ return false; } return true; }