Comment 83 for bug 95507

Revision history for this message
In , Tokoe (tokoe) wrote :

(In reply to comment #57)
Hej Karl,

> In GetSourceList():
>
> >+ // check if application/x-moz-file-promise url is supported.
> >+ // If so, advertise text/uri-list.
> >+ if (strcmp(flavorStr, kFilePromiseURLMime) == 0) {
> >+ GdkAtom urlAtom = gdk_atom_intern(gTextUriListType, FALSE);
> >+ GtkTargetEntry *urlTarget =
> >+ (GtkTargetEntry *)g_malloc(sizeof(GtkTargetEntry));
> >+ urlTarget->target = g_strdup(gTextUriListType);
> >+ urlTarget->flags = 0;
> >+ /* Bug 331198 */
> >+ urlTarget->info = NS_PTR_TO_UINT32(urlAtom);
> >+ targetArray.AppendElement(urlTarget);
> >+ }
>
> It looks like this can be done even when numDragItems > 1.
>
> Though I don't think we want two gTextUriListType targets when both kURLMime
> and kFilePromiseURLMime are supported flavours (unless there's a reason why
> that won't happen). If both kFilePromiseURLMime and kURLMime flavours are
> available, then which should be used in the text/uri-list data? (We won't
> know whether the destination wants to copy or link.) Perhaps they are
> unlikely to both occur together and just picking one will be fine.
So what shall I do? Checking whether an kURLMime/gTextUriListType already exists and only create a new gTextUriListType entry if not?

> I don't think handling multiple files would be too difficult, but even if you
> prefer to only implement this for one file right now, make sure that
> SourceDataGet() is consistent with GetSourceList().
What exactly do you mean with consistent?

> >+ // remove and re-add the text/uri-list flavor to discard any previous
> >+ // data of that flavor
> >+ item->RemoveDataFlavor(gTextUriListType);
> >+ item->AddDataFlavor(gTextUriListType);
> >+
> >+ // set the file:///tmp/dnd_file/<filename> URL for text/uri-list flavor
> >+ item->SetTransferData(gTextUriListType, genericDataWrapper, ucs2Str.Length() * 2);
>
> The side-effect of modifying the transferable here doesn't feel right to me.
> The transferable is an app-internal reference to the data, while the external
> uri list, generated here for the GtkSelectionData for other apps, is likely to
> be different. (Internally the data can be referenced from the original URI,
> rather than from the file intended for external use.)
So how can I return the url of the temporary file instead of changing the transferable?!?

Ciao,
Tobias