Exemplo n.º 1
0
/*
 * Return song information Tuple
 */
static void xs_get_song_tuple_info(Tuple *tuple, xs_tuneinfo_t *info, gint subTune)
{
    gchar *tmpStr;

    tmpStr = str_to_utf8(info->sidName);
    tuple_set_str(tuple, FIELD_TITLE, NULL, tmpStr);
    g_free(tmpStr);
    tmpStr = str_to_utf8(info->sidComposer);
    tuple_set_str(tuple, FIELD_ARTIST, NULL, tmpStr);
    g_free(tmpStr);
    tmpStr = str_to_utf8(info->sidCopyright);
    tuple_set_str(tuple, FIELD_COPYRIGHT, NULL, tmpStr);
    g_free(tmpStr);
    tuple_set_str(tuple, FIELD_CODEC, NULL, info->sidFormat);

#if 0
    switch (info->sidModel) {
        case XS_SIDMODEL_6581: tmpStr = "6581"; break;
        case XS_SIDMODEL_8580: tmpStr = "8580"; break;
        case XS_SIDMODEL_ANY: tmpStr = "ANY"; break;
        default: tmpStr = "?"; break;
    }
    tuple_set_str(tuple, -1, "sid-model", tmpStr);
#endif

    /* Get sub-tune information, if available */
    if (subTune < 0 || info->startTune > info->nsubTunes)
        subTune = info->startTune;

    if (subTune > 0 && subTune <= info->nsubTunes) {
        gint tmpInt = info->subTunes[subTune - 1].tuneLength;
        tuple_set_int(tuple, FIELD_LENGTH, NULL, (tmpInt < 0) ? -1 : tmpInt * 1000);

#if 0
        tmpInt = info->subTunes[subTune - 1].tuneSpeed;
        if (tmpInt > 0) {
            switch (tmpInt) {
            case XS_CLOCK_PAL: tmpStr = "PAL"; break;
            case XS_CLOCK_NTSC: tmpStr = "NTSC"; break;
            case XS_CLOCK_ANY: tmpStr = "ANY"; break;
            case XS_CLOCK_VBI: tmpStr = "VBI"; break;
            case XS_CLOCK_CIA: tmpStr = "CIA"; break;
            default:
                g_snprintf(tmpStr2, sizeof(tmpStr2), "%dHz", tmpInt);
                tmpStr = tmpStr2;
                break;
            }
        } else
            tmpStr = "?";

        tuple_set_str(tuple, -1, "sid-speed", tmpStr);
#endif
    } else
        subTune = 1;

    tuple_set_int(tuple, FIELD_SUBSONG_NUM, NULL, info->nsubTunes);
    tuple_set_int(tuple, FIELD_SUBSONG_ID, NULL, subTune);
    tuple_set_int(tuple, FIELD_TRACK_NUMBER, NULL, subTune);
}
Exemplo n.º 2
0
static gchar * aosd_trigger_utf8convert (const gchar * str)
{
  if ( global_config->osd->text.utf8conv_disable == FALSE )
    return str_to_utf8( str );
  else
    return g_strdup( str );
}
Exemplo n.º 3
0
void
rfs4_set_deleg_response(rfs4_deleg_state_t *dsp, open_delegation4 *dp,
    nfsace4 *ace,  int recall)
{
	open_write_delegation4 *wp;
	open_read_delegation4 *rp;
	nfs_space_limit4 *spl;
	nfsace4 nace;

	/*
	 * We need to allocate a new copy of the who string.
	 * this string will be freed by the rfs4_op_open dis_resfree
	 * routine. We need to do this allocation since replays will
	 * be allocated and rfs4_compound can't tell the difference from
	 * a replay and an inital open. N.B. if an ace is passed in, it
	 * the caller's responsibility to free it.
	 */

	if (ace == NULL) {
		/*
		 * Default is to deny all access, the client will have
		 * to contact the server.  XXX Do we want to actually
		 * set a deny for every one, or do we simply want to
		 * construct an entity that will match no one?
		 */
		nace.type = ACE4_ACCESS_DENIED_ACE_TYPE;
		nace.flag = 0;
		nace.access_mask = ACE4_VALID_MASK_BITS;
		(void) str_to_utf8(ACE4_WHO_EVERYONE, &nace.who);
	} else {
		nace.type = ace->type;
		nace.flag = ace->flag;
		nace.access_mask = ace->access_mask;
		(void) utf8_copy(&ace->who, &nace.who);
	}

	dp->delegation_type = dsp->rds_dtype;

	switch (dsp->rds_dtype) {
	case OPEN_DELEGATE_NONE:
		break;
	case OPEN_DELEGATE_READ:
		rp = &dp->open_delegation4_u.read;
		rp->stateid = dsp->rds_delegid.stateid;
		rp->recall = (bool_t)recall;
		rp->permissions = nace;
		break;
	case OPEN_DELEGATE_WRITE:
		wp = &dp->open_delegation4_u.write;
		wp->stateid = dsp->rds_delegid.stateid;
		wp->recall = (bool_t)recall;
		spl = &wp->space_limit;
		spl->limitby = NFS_LIMIT_SIZE;
		spl->nfs_space_limit4_u.filesize = 0;
		wp->permissions = nace;
		break;
	}
}
Exemplo n.º 4
0
static void
set_tuple_str(Tuple *tuple, const gint nfield, const gchar *field,
    vorbis_comment *comment, gchar *key)
{
    gchar *str = vorbis_comment_query(comment, key, 0);
    if (str != NULL) {
        gchar *tmp = str_to_utf8(str);
        tuple_set_str(tuple, nfield, field, tmp);
        g_free(tmp);
    }
}
Exemplo n.º 5
0
static gboolean
watch_extract_thread (gpointer user_data)
{
	ExtractProgress ep;

	g_static_mutex_lock (&extractProgressM);
	memcpy (&ep, &extractProgress, sizeof (ExtractProgress));
	g_static_mutex_unlock (&extractProgressM);

	if (ep.status != lastKnownProgress.status) {
		switch (ep.status) {
		case STATUS_INIT:
			break;
		case STATUS_MKDIR:
			gtk_progress_bar_set_text (GTK_PROGRESS_BAR (W(progress)),
				_("Creating folders..."));
			break;
		case STATUS_EXTRACT:
			gtk_progress_bar_set_text (GTK_PROGRESS_BAR (W(progress)),
				_("0%"));
			break;
		case STATUS_DONE:
			break;
		default:
			break;
		};
	}

	if (ep.current != lastKnownProgress.current || ep.max != lastKnownProgress.max) {
		if (ep.max == 0)
			gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (W(progress)), 0.0);
		else
			gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (W(progress)),
				(gdouble) ep.current / (gdouble) ep.max);

		if (ep.status == STATUS_EXTRACT && ep.file) {
			char *tmp, *basename;

			basename = g_path_get_basename (ep.file);
			tmp = str_to_utf8 (basename, NULL);
			g_free (basename);
			basename = g_strdup_printf ("%.1f%%: %s",
				((gdouble) ep.current / (gdouble) ep.max) * 100, tmp);
			g_free (tmp);

			gtk_progress_bar_set_text (GTK_PROGRESS_BAR (W(progress)),
				basename);
			g_free (basename);
		}
	}

	memcpy (&lastKnownProgress, &ep, sizeof (ExtractProgress));
	return TRUE;
}
Exemplo n.º 6
0
static char * read_win_text (VFSFile * file)
{
    int64_t size = vfs_fsize (file);
    if (size < 1)
        return NULL;

    char * raw = malloc (size + 1);
    size = vfs_fread (raw, 1, size, file);
    raw[size] = 0;

    strip_char (raw, '\r');
    char * text = str_to_utf8 (raw);
    free (raw);
    return text;
}
Exemplo n.º 7
0
char * construct_uri (const char * path, const char * reference)
{
    /* URI */
    if (strstr (path, "://"))
        return str_get (path);

    /* absolute filename */
#ifdef _WIN32
    if (path[0] && path[1] == ':' && path[2] == '\\')
#else
    if (path[0] == '/')
#endif
        return filename_to_uri (path);

    /* relative path */
    const char * slash = strrchr (reference, '/');
    if (! slash)
        return NULL;

    char * utf8 = str_to_utf8 (path, -1);
    if (! utf8)
        return NULL;

    int pathlen = slash + 1 - reference;

    char buf[pathlen + 3 * strlen (utf8) + 1];
    memcpy (buf, reference, pathlen);

    if (get_bool (NULL, "convert_backslash"))
    {
        SCOPY (tmp, utf8);
        str_replace_char (tmp, '\\', '/');
        str_encode_percent (tmp, -1, buf + pathlen);
    }
    else
        str_encode_percent (utf8, -1, buf + pathlen);

    str_unref (utf8);
    return str_get (buf);
}
Exemplo n.º 8
0
/**
 * Builds the index GtkTreeModel from DjVu s-expr
 *
 * (bookmarks
 *   ("title1" "dest1"
 *     ("title12" "dest12"
 *       ... )
 *     ... )
 *   ("title2" "dest2"
 *     ... )
 *   ... )
 */
static void
build_tree (const DjvuDocument *djvu_document,
	    GtkTreeModel       *model,
	    GtkTreeIter        *parent,
	    miniexp_t           iter)
{
	const char *title, *link_dest;
	char *title_markup;

	EvLinkAction *ev_action = NULL;
	EvLink *ev_link = NULL;
	GtkTreeIter tree_iter;

	if (miniexp_car (iter) == miniexp_symbol ("bookmarks")) {
		/* The (bookmarks) cons */
		iter = miniexp_cdr (iter);
	} else if ( miniexp_length (iter) >= 2 ) {
		gchar *utf8_title = NULL;
		
		/* An entry */
		if (!string_from_miniexp (miniexp_car (iter), &title)) goto unknown_entry;
		if (!string_from_miniexp (miniexp_cadr (iter), &link_dest)) goto unknown_entry;

		
		if (!g_utf8_validate (title, -1, NULL)) {
			utf8_title = str_to_utf8 (title);
			title_markup = g_markup_escape_text (utf8_title, -1);
		} else {
			title_markup = g_markup_escape_text (title, -1);
		}

		ev_action = get_djvu_link_action (djvu_document, link_dest, -1);

		if (ev_action) {
			ev_link = ev_link_new (utf8_title ? utf8_title : title, ev_action);
			gtk_tree_store_append (GTK_TREE_STORE (model), &tree_iter, parent);
			gtk_tree_store_set (GTK_TREE_STORE (model), &tree_iter,
					    EV_DOCUMENT_LINKS_COLUMN_MARKUP, title_markup,
					    EV_DOCUMENT_LINKS_COLUMN_LINK, ev_link,
					    EV_DOCUMENT_LINKS_COLUMN_EXPAND, FALSE,
					    -1);
			g_object_unref (ev_action);
			g_object_unref (ev_link);
		} else {
			gtk_tree_store_append (GTK_TREE_STORE (model), &tree_iter, parent);
			gtk_tree_store_set (GTK_TREE_STORE (model), &tree_iter,
					    EV_DOCUMENT_LINKS_COLUMN_MARKUP, title_markup,
					    EV_DOCUMENT_LINKS_COLUMN_EXPAND, FALSE,
					    -1);
		}

		g_free (title_markup);
		g_free (utf8_title);
		iter = miniexp_cddr (iter);
		parent = &tree_iter;
	} else {
		goto unknown_entry;
	}

	for (; iter != miniexp_nil; iter = miniexp_cdr (iter)) {
		build_tree (djvu_document, model, parent, miniexp_car (iter));
	}
	return;

 unknown_entry:
	g_warning ("DjvuLibre error: Unknown entry in bookmarks");
	return;
}
Exemplo n.º 9
0
/*
 * Place the actual cb_recall otw call to client.
 */
static void
rfs4_do_cb_recall(rfs4_deleg_state_t *dsp, bool_t trunc)
{
	CB_COMPOUND4args	cb4_args;
	CB_COMPOUND4res		cb4_res;
	CB_RECALL4args		*rec_argp;
	CB_RECALL4res		*rec_resp;
	nfs_cb_argop4		*argop;
	int			numops;
	int			argoplist_size;
	struct timeval		timeout;
	nfs_fh4			*fhp;
	enum clnt_stat		call_stat;

	/*
	 * set up the compound args
	 */
	numops = 1;	/* CB_RECALL only */

	argoplist_size = numops * sizeof (nfs_cb_argop4);
	argop = kmem_zalloc(argoplist_size, KM_SLEEP);
	argop->argop = OP_CB_RECALL;
	rec_argp = &argop->nfs_cb_argop4_u.opcbrecall;

	(void) str_to_utf8("cb_recall", &cb4_args.tag);
	cb4_args.minorversion = CB4_MINORVERSION;
	/* cb4_args.callback_ident is set in rfs4_do_callback() */
	cb4_args.array_len = numops;
	cb4_args.array = argop;

	/*
	 * fill in the args struct
	 */
	bcopy(&dsp->rds_delegid.stateid, &rec_argp->stateid, sizeof (stateid4));
	rec_argp->truncate = trunc;

	fhp = &dsp->rds_finfo->rf_filehandle;
	rec_argp->fh.nfs_fh4_val = kmem_alloc(sizeof (char) *
	    fhp->nfs_fh4_len, KM_SLEEP);
	nfs_fh4_copy(fhp, &rec_argp->fh);

	/* Keep track of when we did this for observability */
	dsp->rds_time_recalled = gethrestime_sec();

	/*
	 * Set up the timeout for the callback and make the actual call.
	 * Timeout will be 80% of the lease period for this server.
	 */
	timeout.tv_sec = (rfs4_lease_time * 80) / 100;
	timeout.tv_usec = 0;

	DTRACE_NFSV4_3(cb__recall__start, rfs4_client_t *, dsp->rds_client,
	    rfs4_deleg_state_t *, dsp, CB_RECALL4args *, rec_argp);

	call_stat = rfs4_do_callback(dsp->rds_client, &cb4_args, &cb4_res,
	    timeout);

	rec_resp = (cb4_res.array_len == 0) ? NULL :
	    &cb4_res.array[0].nfs_cb_resop4_u.opcbrecall;

	DTRACE_NFSV4_3(cb__recall__done, rfs4_client_t *, dsp->rds_client,
	    rfs4_deleg_state_t *, dsp, CB_RECALL4res *, rec_resp);

	if (call_stat != RPC_SUCCESS || cb4_res.status != NFS4_OK) {
		rfs4_return_deleg(dsp, TRUE);
	}

	rfs4freeargres(&cb4_args, &cb4_res);
}
Exemplo n.º 10
0
unsigned long
fill_filelist ()
{
	long i;
	unsigned long num = 0;
	GtkTreeIter iter = {};
	gchar *search;
	GPatternSpec *pattern = NULL;

	filling = TRUE;

	gtk_list_store_clear (GTK_LIST_STORE (filelist));
	search = (gchar *) gtk_entry_get_text (GTK_ENTRY (W(searchentry)));
	if (search && *search) {
		if (!strchr (search, '*')) {
			search = g_strdup_printf ("*%s*", search);
			pattern = g_pattern_spec_new (search);
			g_free (search);
		} else
			pattern = g_pattern_spec_new (search);
	}

	/* Detach list model from view to make insertion faster */
	g_object_ref (filelist);
	gtk_tree_view_set_model (GTK_TREE_VIEW (W(filelist)), NULL);

	/* We add items to the list in reversed order because for some reason
	   the list reverses the order again. i is not an unsigned long because
	   it will conflict with 'i >= 0' and 'i--' */
	for (i = (long) document.grf->nfiles - 1; i >= 0; i--) {
		char *filename = NULL;
		char *size = NULL;
		char *type;

		if (!document.grf->files[i].real_len)
			continue;

		/* Do not display folders */
		if (GRFFILE_IS_DIR(document.grf->files[i]))
			continue;

		/* Attempt to convert the filename to UTF-8 */
		if (!document.grf->files[i].name) {
			printf("%ld: %s\n", i, document.grf->files[i].name);
			continue;
		}
		filename = str_to_utf8 (document.grf->files[i].name, NULL);
		if (!filename)
			continue;

		if (pattern && !g_pattern_match_string (pattern, filename)) {
			g_free (filename);
			continue;
		}

		size = friendly_size_name (document.grf->files[i].real_len);
		type = get_type_name (filename);

		/* Add to list */
		gtk_list_store_prepend (GTK_LIST_STORE (filelist), &iter);
		gtk_list_store_set (GTK_LIST_STORE (filelist), &iter,
			INDEX_COL, i,
			DISPLAY_COL, filename,
			TYPE_COL, type,
			SIZE_COL, document.grf->files[i].real_len,
			SIZE_DISPLAY_COL, size,
			-1);
		num++;

		g_free (size);
		g_free (filename);
		g_free (type);
	}

	/* Re-attach model */
	gtk_tree_view_set_model (GTK_TREE_VIEW (W(filelist)), filelist);
	g_object_unref (filelist);

	filling = FALSE;

	if (pattern)
		g_pattern_spec_free (pattern);
	return num;
}