Пример #1
0
static void
process_photosetsphotos_result (const gchar *xml_result, gpointer user_data)
{
  GFlickrData *data = (GFlickrData *) user_data;
  GList *list = NULL;
  xmlDocPtr doc;
  xmlNodePtr node;

  doc = xmlReadMemory (xml_result, xmlStrlen ((xmlChar*) xml_result), NULL,
                       NULL, XML_PARSE_RECOVER | XML_PARSE_NOBLANKS);
  node = xmlDocGetRootElement (doc);

  /* Check result is ok */
  if (!node || !result_is_correct (node)) {
    data->list_cb (data->flickr, NULL, data->user_data);
  } else {
    node = node->xmlChildrenNode;

    /* Now we're at "photoset page" node */
    node = node->xmlChildrenNode;
    while (node) {
      list = g_list_prepend (list, get_photo (node));
      node = node->next;
    }

    data->list_cb (data->flickr, g_list_reverse (list), data->user_data);
    g_list_free_full (list, (GDestroyNotify) g_hash_table_unref);
  }
  g_object_unref (data->flickr);
  g_slice_free (GFlickrData, data);
  xmlFreeDoc (doc);
}
Пример #2
0
/*
 * Class:     com_vmc_ipc_proxy_IpcProxy
 * Method:    takePhoto
 * Signature: (Ljava/lang/String;Ljava/lang/String;Z)V
 */
JNIEXPORT void JNICALL Java_com_vmc_ipc_proxy_IpcProxy_takePhoto
  (JNIEnv * env, jobject, jstring dstDir, jstring name, jboolean){
	LOGI("-->Java_com_vmc_ipc_proxy_IpcProxy_takePhoto");
	std::string sDir,sName;	
	
	const char *tmp = env->GetStringUTFChars(dstDir, NULL);
	sDir = tmp;
	env->ReleaseStringUTFChars(dstDir, tmp);

	
	tmp = env->GetStringUTFChars(name, NULL);
	sName = tmp;
	env->ReleaseStringUTFChars(name, tmp);

	LOGI("Java_com_vmc_ipc_proxy_IpcProxy_takePhoto dir:%s name:%s",sDir.c_str(),sName.c_str());
#if 1	
	get_photo((char *)sDir.c_str(),(char *)sName.c_str(),false);
#else
	rapidjson::Document doc;
	char buf[50];
	doc.SetObject();
	doc.AddMember("cmd",(uint64_t)CMD_RESTART_SERVER,doc.GetAllocator());
	g_client->SendAsyn(doc,true);
#endif
}
Пример #3
0
static void
process_photo_result (const gchar *xml_result, gpointer user_data)
{
  xmlDocPtr doc;
  xmlNodePtr node;
  GFlickrData *data = (GFlickrData *) user_data;
  GHashTable *photo;

  doc = xmlReadMemory (xml_result, xmlStrlen ((xmlChar*) xml_result), NULL,
                       NULL, XML_PARSE_RECOVER | XML_PARSE_NOBLANKS);
  node = xmlDocGetRootElement (doc);

  /* Check result is ok */
  if (!node || !result_is_correct (node)) {
    data->hashtable_cb (data->flickr, NULL, data->user_data);
  } else {
    node = node->xmlChildrenNode;

    photo = get_photo (node);
    data->hashtable_cb (data->flickr, photo, data->user_data);
    g_hash_table_unref (photo);
  }
  g_object_unref (data->flickr);
  g_slice_free (GFlickrData, data);
  xmlFreeDoc (doc);
}
Пример #4
0
/* Looks for the photo specified in the arguments.
 * Returns pointer to the stored cached_information
 * or 0 if not found.
 */
cached_information *photo_lookup(const char *photoset, const char *photo) {
    cached_photo *cp;
    cached_information *ci_copy = NULL;

    pthread_rwlock_rdlock(&cache_lock);
    if((cp = get_photo(photoset, photo)))
        ci_copy = copy_cached_info(&(cp->ci));
    pthread_rwlock_unlock(&cache_lock);

    return ci_copy;
}
Пример #5
0
int get_photo_dirty(const char *photoset, const char *photo) {
    cached_photo *cp;
    unsigned short dirty;

    pthread_rwlock_rdlock(&cache_lock);
    if(!(cp = get_photo(photoset, photo))) {
        pthread_rwlock_unlock(&cache_lock);
        return FAIL;
    }
    dirty = cp->ci.dirty;
    pthread_rwlock_unlock(&cache_lock);

    return dirty;
}
Пример #6
0
int set_photo_dirty(const char *photoset, const char *photo, unsigned short dirty) {
    cached_photo *cp;

    pthread_rwlock_wrlock(&cache_lock);
    if(!(cp = get_photo(photoset, photo))) {
        pthread_rwlock_unlock(&cache_lock);
        return FAIL;
    }

    cp->ci.dirty = dirty;
    pthread_rwlock_unlock(&cache_lock);

    return SUCCESS;
}
Пример #7
0
/* Sets the photos size */
int set_photo_size(const char *photoset, const char *photo, unsigned int newsize) {
    cached_photo *cp;

    pthread_rwlock_wrlock(&cache_lock);
    if(!(cp = get_photo(photoset, photo))) {
        pthread_rwlock_unlock(&cache_lock);
        return FAIL;
    }

    cp->ci.size = newsize;
    pthread_rwlock_unlock(&cache_lock);

    return SUCCESS;
}
Пример #8
0
/* Renames the photo specified in the args to the
 * new name.
 */
int set_photo_name(const char *photoset, const char *photo, const char *newname) {
    cached_photo *cp;

    pthread_rwlock_wrlock(&cache_lock);
    if(!(cp = get_photo(photoset, photo))) {
        pthread_rwlock_unlock(&cache_lock);
        return FAIL;
    }

    flickcurl_photos_setMeta(fc, cp->ci.id, newname, "");
    last_cleaned = 0;
    pthread_rwlock_unlock(&cache_lock);
    return SUCCESS;
}
Пример #9
0
/* Returns the URI used to get the actual image of
 * picture.
 */
char *get_photo_uri(const char *photoset, const char *photo) {
    cached_photo *cp;
    char *uri_copy = NULL;

    pthread_rwlock_rdlock(&cache_lock);
    if((cp = get_photo(photoset, photo))) {
        if( cp->uri ) {
            uri_copy = strdup(cp->uri);
        }
    }
    pthread_rwlock_unlock(&cache_lock);

    return uri_copy;
}
Пример #10
0
/** Print a line for each remote definition in lircd.conf file on path. */
void print_remotes(const char* path)
{
	char my_path[256];
	char photo[256];
	char lircmd[256];
	struct ir_remote* r;
	FILE* f;
	const char* dir;
	const char* base;
	const char* timing;

	strncpy(my_path, path, sizeof(my_path));
	base = basename(my_path);
	dir = dirname(my_path);
	if (strrchr(dir, '/') != NULL)
		dir = strrchr(dir, '/') + 1;
	f = fopen(path, "r");
	if (f == NULL) {
		fprintf(stderr, "Cannot open %s (!)\n", path);
		return;
	}
	r = read_config(f, path);
	if (opt_silent)
		return;
	while (r != NULL && r != (void*)-1) {
		timing = r->pzero != 0 || r->pzero != 0 || is_raw(r) ?
			 "timing" : "no_timing";
		strncpy(photo, path, sizeof(photo));
		get_photo(path, photo, sizeof(photo));
		get_lircmd(path, lircmd, sizeof(lircmd));
		printf("%s;%s;%s;%s;%s;%s;%s;%s\n",
		       dir,
		       base,
		       lircmd,
		       photo,
		       r->name,
		       timing,
		       is_raw(r) ? "raw" : "no_raw",
		       r->driver != NULL ? r->driver : "no_driver");
		fflush(stdout);
		if (opt_dump)
			fprint_remote(stdout, r, "Dumped by lirc-lsremotes");
		r = r->next;
	}
	;
	fclose(f);
}