Back to index

lightning-sunbird  0.9+nobinonly
Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | Friends
nsDragService Class Reference

Native BeOS DragService wrapper. More...

#include <nsDragService.h>

Inheritance diagram for nsDragService:
Inheritance graph
[legend]
Collaboration diagram for nsDragService:
Collaboration graph
[legend]

List of all members.

Public Types

enum  { DND_NONE = 0 }
 the dragFlags returned by most public methods fall into two groups More...
enum  { DND_NATIVEDRAG = 1 }
enum  { DND_MOZDRAG = 2 }
enum  { DND_INDROP = 4 }
enum  { DND_DRAGSTATUS = DND_NATIVEDRAG | DND_MOZDRAG | DND_INDROP }
enum  { DND_DISPATCHENTEREVENT = 16 }
 tasks the caller should perform More...
enum  { DND_DISPATCHEVENT = 32 }
enum  { DND_GETDRAGOVERRESULT = 64 }
enum  { DND_EXITSESSION = 128 }

Public Member Functions

 nsDragService ()
virtual ~nsDragService ()
NS_DECL_ISUPPORTS_INHERITED
NS_IMETHOD 
InvokeDragSession (nsIDOMNode *aDOMNode, nsISupportsArray *anArrayTransferables, nsIScriptableRegion *aRegion, PRUint32 aActionType)
NS_IMETHOD StartDragSession ()
NS_IMETHOD EndDragSession ()
NS_IMETHOD GetNumDropItems (PRUint32 *aNumItems)
NS_IMETHOD GetData (nsITransferable *aTransferable, PRUint32 aItemIndex)
NS_IMETHOD IsDataFlavorSupported (const char *aDataFlavor, PRBool *_retval)
NS_IMETHOD GetCanDrop (PRBool *aCanDrop)
NS_IMETHOD SetCanDrop (PRBool aCanDrop)
NS_IMETHOD UpdateDragMessageIfNeeded (BMessage *aDragMessage)
NS_IMETHOD TransmitData (BMessage *aNegotiationReply)
 nsDragService ()
virtual ~nsDragService ()
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIOBSERVER NS_IMETHOD 
InvokeDragSession (nsIDOMNode *aDOMNode, nsISupportsArray *anArrayTransferables, nsIScriptableRegion *aRegion, PRUint32 aActionType)
NS_IMETHOD StartDragSession ()
NS_IMETHOD EndDragSession ()
NS_IMETHOD SetCanDrop (PRBool aCanDrop)
NS_IMETHOD GetCanDrop (PRBool *aCanDrop)
NS_IMETHOD GetNumDropItems (PRUint32 *aNumItems)
NS_IMETHOD GetData (nsITransferable *aTransferable, PRUint32 aItemIndex)
NS_IMETHOD IsDataFlavorSupported (const char *aDataFlavor, PRBool *_retval)
NS_IMETHOD TargetSetLastContext (GtkWidget *aWidget, GdkDragContext *aContext, guint aTime)
NS_IMETHOD TargetStartDragMotion (void)
NS_IMETHOD TargetEndDragMotion (GtkWidget *aWidget, GdkDragContext *aContext, guint aTime)
NS_IMETHOD TargetDataReceived (GtkWidget *aWidget, GdkDragContext *aContext, gint aX, gint aY, GtkSelectionData *aSelection_data, guint aInfo, guint32 aTime)
NS_IMETHOD TargetSetTimeCallback (nsIDragSessionGTKTimeCB aCallback)
void SourceEndDrag (void)
void SourceDataGet (GtkWidget *widget, GdkDragContext *context, GtkSelectionData *selection_data, guint info, guint32 aTime)
 nsDragService ()
virtual ~nsDragService ()
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIOBSERVER NS_IMETHOD 
InvokeDragSession (nsIDOMNode *aDOMNode, nsISupportsArray *anArrayTransferables, nsIScriptableRegion *aRegion, PRUint32 aActionType)
NS_IMETHOD StartDragSession ()
NS_IMETHOD EndDragSession ()
NS_IMETHOD SetCanDrop (PRBool aCanDrop)
NS_IMETHOD GetCanDrop (PRBool *aCanDrop)
NS_IMETHOD GetNumDropItems (PRUint32 *aNumItems)
NS_IMETHOD GetData (nsITransferable *aTransferable, PRUint32 aItemIndex)
NS_IMETHOD IsDataFlavorSupported (const char *aDataFlavor, PRBool *_retval)
NS_IMETHOD TargetSetLastContext (GtkWidget *aWidget, GdkDragContext *aContext, guint aTime)
NS_IMETHOD TargetStartDragMotion (void)
NS_IMETHOD TargetEndDragMotion (GtkWidget *aWidget, GdkDragContext *aContext, guint aTime)
NS_IMETHOD TargetDataReceived (GtkWidget *aWidget, GdkDragContext *aContext, gint aX, gint aY, GtkSelectionData *aSelection_data, guint aInfo, guint32 aTime)
NS_IMETHOD TargetSetTimeCallback (nsIDragSessionGTKTimeCB aCallback)
void SourceEndDrag (void)
void SourceDataGet (GtkWidget *widget, GdkDragContext *context, GtkSelectionData *selection_data, guint info, guint32 aTime)
 nsDragService ()
virtual ~nsDragService ()
NS_DECL_ISUPPORTS_INHERITED
NS_IMETHOD 
InvokeDragSession (nsIDOMNode *aDOMNode, nsISupportsArray *anArrayTransferables, nsIScriptableRegion *aRegion, PRUint32 aActionType)
NS_IMETHOD GetData (nsITransferable *aTransferable, PRUint32 aItemIndex)
NS_IMETHOD IsDataFlavorSupported (const char *aDataFlavor, PRBool *_retval)
NS_IMETHOD GetNumDropItems (PRUint32 *aNumItems)
NS_IMETHOD SetDragAction (PRUint32 anAction)
NS_IMETHOD SetDragReference (DragReference aDragRef)
 Since the drag may originate in an external application, we need some way of communicating the DragManager's DragRef to the session so it can use it when filling in data requests.
 nsDragService ()
virtual ~nsDragService ()
NS_DECL_ISUPPORTS_INHERITED
NS_IMETHOD 
InvokeDragSession (nsIDOMNode *aDOMNode, nsISupportsArray *aTransferables, nsIScriptableRegion *aRegion, PRUint32 aActionType)
NS_IMETHOD StartDragSession ()
NS_IMETHOD EndDragSession ()
NS_IMETHOD GetNumDropItems (PRUint32 *aNumDropItems)
NS_IMETHOD GetData (nsITransferable *aTransferable, PRUint32 aItemIndex)
NS_IMETHOD IsDataFlavorSupported (const char *aDataFlavor, PRBool *_retval)
NS_IMETHOD DragOverMsg (PDRAGINFO pdinfo, MRESULT &mr, PRUint32 *dragFlags)
NS_IMETHOD GetDragoverResult (MRESULT &mr)
NS_IMETHOD DragLeaveMsg (PDRAGINFO pdinfo, PRUint32 *dragFlags)
NS_IMETHOD DropHelpMsg (PDRAGINFO pdinfo, PRUint32 *dragFlags)
NS_IMETHOD ExitSession (PRUint32 *dragFlags)
NS_IMETHOD DropMsg (PDRAGINFO pdinfo, HWND hwnd, PRUint32 *dragFlags)
NS_IMETHOD RenderCompleteMsg (PDRAGTRANSFER pdxfer, USHORT usResult, PRUint32 *dragFlags)
 nsDragService ()
virtual ~nsDragService ()
NS_DECL_ISUPPORTS_INHERITED
NS_IMETHOD 
SetNativeDndData (PtWidget_t *widget, PhEvent_t *event)
NS_IMETHOD InvokeDragSession (nsIDOMNode *aDOMNode, nsISupportsArray *anArrayTransferables, nsIScriptableRegion *aRegion, PRUint32 aActionType)
NS_IMETHOD GetData (nsITransferable *aTransferable, PRUint32 anItem)
NS_IMETHOD GetNumDropItems (PRUint32 *aNumItems)
NS_IMETHOD IsDataFlavorSupported (const char *aDataFlavor, PRBool *_retval)
NS_IMETHOD SetDropData (char *data)
void SourceEndDrag (void)
 nsDragService ()
virtual ~nsDragService ()
NS_DECL_ISUPPORTS_INHERITED
NS_IMETHOD 
InvokeDragSession (nsIDOMNode *aDOMNode, nsISupportsArray *anArrayTransferables, nsIScriptableRegion *aRegion, PRUint32 aActionType)
NS_IMETHOD StartDragSession ()
NS_IMETHOD EndDragSession ()
NS_IMETHOD SetCanDrop (PRBool aCanDrop)
NS_IMETHOD GetCanDrop (PRBool *aCanDrop)
NS_IMETHOD GetNumDropItems (PRUint32 *aNumItems)
NS_IMETHOD GetData (nsITransferable *aTransferable, PRUint32 aItemIndex)
NS_IMETHOD IsDataFlavorSupported (const char *aDataFlavor, PRBool *_retval)
NS_IMETHOD SetDragReference (QMimeSource *aDragRef)
 Since the drag may originate in an external application, we need some way of communicating the QDragObject to the session so it can use it when filling in data requests.
 nsDragService ()
virtual ~nsDragService ()
NS_IMETHOD InvokeDragSession (nsIDOMNode *aDOMNode, nsISupportsArray *anArrayTransferables, nsIScriptableRegion *aRegion, PRUint32 aActionType)
NS_IMETHOD GetData (nsITransferable *aTransferable, PRUint32 anItem)
NS_IMETHOD GetNumDropItems (PRUint32 *aNumItems)
NS_IMETHOD IsDataFlavorSupported (const char *aDataFlavor, PRBool *_retval)
NS_IMETHOD EndDragSession ()
NS_IMETHOD SetIDataObject (IDataObject *aDataObj)
NS_IMETHOD StartInvokingDragSession (IDataObject *aDataObj, PRUint32 aActionType)
NS_DECL_ISUPPORTS_INHERITED nsDragService ()
virtual ~nsDragService ()
NS_IMETHOD InvokeDragSession (nsIDOMNode *aDOMNode, nsISupportsArray *anArrayTransferables, nsIScriptableRegion *aRegion, PRUint32 aActionType)
NS_IMETHOD StartDragSession ()
NS_IMETHOD EndDragSession ()
NS_IMETHOD GetCurrentSession (nsIDragSession **aSession)
NS_IMETHOD SetCanDrop (PRBool aCanDrop)
NS_IMETHOD GetCanDrop (PRBool *aCanDrop)
NS_IMETHOD GetNumDropItems (PRUint32 *aNumItems)
NS_IMETHOD GetData (nsITransferable *aTransferable, PRUint32 anItemIndex)
NS_IMETHOD IsDataFlavorSupported (const char *aDataFlavor, PRBool *_retval)
NS_IMETHOD IsDragging (PRBool *result)
NS_IMETHOD UpdatePosition (PRInt32 x, PRInt32 y)
void suppress ()
 Increase/decrease dragging suppress level by one.
void unsuppress ()
void invokeDragSession (in nsIDOMNode aDOMNode, in nsISupportsArray aTransferables, in nsIScriptableRegion aRegion, in unsigned long aActionType)
 Starts a modal drag session with an array of transaferables.
nsIDragSession getCurrentSession ()
 Returns the current Drag Session.
void startDragSession ()
 Tells the Drag Service to start a drag session.
void endDragSession ()
 Tells the Drag Service to end a drag session.
void getData (in nsITransferable aTransferable, in unsigned long aItemIndex)
 Get data from a Drag&Drop.
boolean isDataFlavorSupported (in string aDataFlavor)
 Check to set if ant of the native data on the clipboard matches this data flavor.
void observe (in nsISupports aSubject, in string aTopic, in wstring aData)
 Observe will be called when there is a notification for the topic |aTopic|.

Public Attributes

PRUint32 mActionType
const long DRAGDROP_ACTION_NONE = 0
const long DRAGDROP_ACTION_COPY = 1
const long DRAGDROP_ACTION_MOVE = 2
const long DRAGDROP_ACTION_LINK = 4
attribute boolean canDrop
 Set the current state of the drag whether it can be dropped or not.
attribute unsigned long dragAction
 Sets the action (copy, move, link, et.c) for the current drag.
attribute nsSize targetSize
 Sets the current width and height if the drag target area.
readonly attribute unsigned long numDropItems
 Get the number items that were dropped.
readonly attribute nsIDOMDocument sourceDocument
 The document where the drag was started, which will be null if the drag originated outside the application.
readonly attribute nsIDOMNode sourceNode
 The dom node that was originally dragged to start the session, which will be null if the drag originated outside the application.

Protected Member Functions

NS_IMETHOD NativeDragEnter (PDRAGINFO pdinfo)
NS_IMETHOD NativeDrop (PDRAGINFO pdinfo, HWND hwnd, PRBool *rendering)
NS_IMETHOD NativeRenderComplete (PDRAGTRANSFER pdxfer, USHORT usResult)
NS_IMETHOD NativeDataToTransferable (PCSZ pszText, PCSZ pszTitle, PRBool isUrl)
nsresult SaveAsContents (PCSZ szDest, nsIURL *aURL)
nsresult SaveAsURL (PCSZ szDest, nsIURI *aURI)
nsresult SaveAsText (PCSZ szDest, nsISupportsString *aString)
nsresult GetUrlAndTitle (nsISupports *aGenericData, char **aTargetName)
nsresult GetUniTextTitle (nsISupports *aGenericData, char **aTargetName)
QDragObject * RegisterDragFlavors (nsITransferable *transferable)
nsDataObjCollectionGetDataObjCollection (IDataObject *aDataObj)
PRBool IsCollectionObject (IDataObject *inDataObj)
virtual void GetFrameFromNode (nsIDOMNode *inNode, nsIFrame **outFrame, nsPresContext **outContext)

Static Protected Member Functions

static nsEventStatus PR_CALLBACK Callback (nsGUIEvent *event)

Protected Attributes

nsCOMPtr< nsISupportsArraymSourceDataItems
HWND mDragWnd
char * mMimeType
nsCOMPtr< nsISupports > mSourceData
IDropSource * mNativeDragSrc
nsNativeDragTargetmNativeDragTarget
IDataObject * mDataObject
PRPackedBool mDoingDrag
PRUint32 mDragAction
nsSize mTargetSize
nsCOMPtr< nsISupportsArraymTransArray
nsCOMPtr< nsIDOMNodemSourceNode
nsCOMPtr< nsIDOMDocumentmSourceDocument
PRUint32 mSuppressLevel

Private Member Functions

void ResetDragInfo (void)
PRPackedBool IsDragList (void)
BMessage * CreateDragMessage ()
PRBool IsTargetContextList (void)
void GetTargetDragData (GdkAtom aFlavor)
void TargetResetData (void)
GtkTargetList * GetSourceList (void)
PRBool IsTargetContextList (void)
void GetTargetDragData (GdkAtom aFlavor)
void TargetResetData (void)
GtkTargetList * GetSourceList (void)
char * LookupMimeMappingsForItem (DragReference inDragRef, ItemReference itemRef)
void RegisterDragItemsAndFlavors (nsISupportsArray *inArray, RgnHandle inDragRgn)
PRBool BuildDragRegion (nsIScriptableRegion *inRegion, nsIDOMNode *inNode, RgnHandle ioDragRgn)
OSErr GetDataForFlavor (nsISupportsArray *inDragItems, DragReference inDragRef, unsigned int inItemIndex, FlavorType inFlavor, void **outData, unsigned int *outSize)
nsresult ExtractDataFromOS (DragReference inDragRef, ItemReference inItemRef, ResType inFlavor, void **outBuffer, PRUint32 *outBuffSize)
PRBool ComputeGlobalRectFromFrame (nsIDOMNode *aDOMNode, Rect &outScreenRect)
OSErr GetHFSPromiseDropDirectory (DragReference inDragRef, unsigned int inItemIndex, FlavorType inFlavor, nsILocalFile **outDir)
OSErr SetDropFileInDrag (DragReference inDragRef, unsigned int inItemIndex, FlavorType inFlavor, nsILocalFile *inFile)
void CreateDragCursor (PRUint32 aActionType)

Static Private Member Functions

static const char * FlavorToBeMime (const char *flavor)
static pascal OSErr DragSendDataProc (FlavorType inFlavor, void *inRefCon, ItemReference theItemRef, DragReference inDragRef)

Private Attributes

BMessage * mDragMessage
BString gMimeListType
PRPackedBool mDragIsList
GtkWidget * mTargetWidget
GdkDragContext * mTargetDragContext
guint mTargetTime
PRBool mCanDrop
PRBool mTargetDragDataReceived
voidmTargetDragData
PRUint32 mTargetDragDataLen
GtkWidget * mHiddenWidget
nsIDragSessionGTKTimeCB mTimeCB
DragSendDataUPP mDragSendDataUPP
DragReference mDragRef
nsISupportsArraymDataItems
PRBool mImageDraggingSupported
PtWidget_t * mDndWidget
PtTransportCtrl_t * mNativeCtrl
char * mRawData
char * mFlavourStr
char * mTransportFile
QWidget * mHiddenWidget
QDragObject * mDragObject
nsWidgetmDropWidget

Static Private Attributes

static char * mDndEvent
static int mDndEventLen
static nsWidgetsWidget = nsnull
static Window sWindow
static XlibRgbHandle * sXlibRgbHandle
static DisplaysDisplay
static PRBool mDragging = PR_FALSE

Friends

MRESULT EXPENTRY nsDragWindowProc (HWND, ULONG, MPARAM, MPARAM)

Detailed Description

Native BeOS DragService wrapper.

xlib shell based on gtk

Native Win32 DragService wrapper.

Native Photon DragService wrapper.

Native GTK DragService wrapper.

Definition at line 51 of file nsDragService.h.


Member Enumeration Documentation

anonymous enum [inherited]

the dragFlags returned by most public methods fall into two groups

Mozilla's dragover status

Enumerator:
DND_NONE 

Definition at line 72 of file nsIDragSessionOS2.h.

{ DND_NONE       = 0 };                                     
anonymous enum [inherited]
Enumerator:
DND_NATIVEDRAG 

Definition at line 73 of file nsIDragSessionOS2.h.

{ DND_NATIVEDRAG = 1 };                                     
anonymous enum [inherited]
Enumerator:
DND_MOZDRAG 

Definition at line 74 of file nsIDragSessionOS2.h.

{ DND_MOZDRAG    = 2 };                                     
anonymous enum [inherited]
Enumerator:
DND_INDROP 

Definition at line 75 of file nsIDragSessionOS2.h.

{ DND_INDROP     = 4 };                                     
anonymous enum [inherited]
Enumerator:
DND_DRAGSTATUS 

Definition at line 76 of file nsIDragSessionOS2.h.

anonymous enum [inherited]

tasks the caller should perform

Enumerator:
DND_DISPATCHENTEREVENT 

Definition at line 79 of file nsIDragSessionOS2.h.

anonymous enum [inherited]
Enumerator:
DND_DISPATCHEVENT 

Definition at line 80 of file nsIDragSessionOS2.h.

anonymous enum [inherited]
Enumerator:
DND_GETDRAGOVERRESULT 

Definition at line 81 of file nsIDragSessionOS2.h.

anonymous enum [inherited]
Enumerator:
DND_EXITSESSION 

Definition at line 82 of file nsIDragSessionOS2.h.

{ DND_EXITSESSION        = 128 };

Constructor & Destructor Documentation

Definition at line 86 of file nsDragService.cpp.

{
  // We have to destroy the hidden widget before the event loop stops running.
  nsCOMPtr<nsIObserverService> obsServ =
    do_GetService("@mozilla.org/observer-service;1");
  obsServ->AddObserver(this, "quit-application", PR_FALSE);

  // our hidden source widget
  mHiddenWidget = gtk_invisible_new();
  // make sure that the widget is realized so that
  // we can use it as a drag source.
  gtk_widget_realize(mHiddenWidget);
  // hook up our internal signals so that we can get some feedback
  // from our drag source
  gtk_signal_connect(GTK_OBJECT(mHiddenWidget), "drag_data_get",
                     GTK_SIGNAL_FUNC(invisibleSourceDragDataGet), this);
  gtk_signal_connect(GTK_OBJECT(mHiddenWidget), "drag_end",
                     GTK_SIGNAL_FUNC(invisibleSourceDragEnd), this);

  // set up our logging module
#ifdef PR_LOGGING
  if (!sDragLm)
    sDragLm = PR_NewLogModule("nsDragService");
#endif
  PR_LOG(sDragLm, PR_LOG_DEBUG, ("nsDragService::nsDragService"));
  mTargetWidget = 0;
  mTargetDragContext = 0;
  mTargetTime = 0;
  mCanDrop = PR_FALSE;
  mTimeCB = 0;
  mTargetDragDataReceived = PR_FALSE;
  mTargetDragData = 0;
  mTargetDragDataLen = 0;
}

Here is the call graph for this function:

Definition at line 137 of file nsDragService.cpp.

{
    PR_LOG(sDragLm, PR_LOG_DEBUG, ("nsDragService::~nsDragService"));
    ResetDragInfo();
}

Here is the call graph for this function:

virtual nsDragService::~nsDragService ( ) [virtual]
virtual nsDragService::~nsDragService ( ) [virtual]
virtual nsDragService::~nsDragService ( ) [virtual]
virtual nsDragService::~nsDragService ( ) [virtual]
virtual nsDragService::~nsDragService ( ) [virtual]
virtual nsDragService::~nsDragService ( ) [virtual]
virtual nsDragService::~nsDragService ( ) [virtual]
virtual nsDragService::~nsDragService ( ) [virtual]

Member Function Documentation

PRBool nsDragService::BuildDragRegion ( nsIScriptableRegion inRegion,
nsIDOMNode inNode,
RgnHandle  ioDragRgn 
) [private]

Definition at line 326 of file nsDragService.cpp.

{
  PRBool retVal = PR_TRUE;
  nsCOMPtr<nsIRegion> geckoRegion;
  if ( inRegion )
    inRegion->GetRegion(getter_AddRefs(geckoRegion));
    
#ifdef MOZ_WIDGET_COCOA
  nsGraphicsUtils::SetPortToKnownGoodPort();
  GrafPtr port;
  GDHandle handle;
  ::GetGWorld(&port, &handle);
  if (!IsValidPort(port))
  return NS_ERROR_FAILURE;
#endif

  // create the drag region. Pull out the native mac region from the nsIRegion we're
  // given, copy it, inset it one pixel, and subtract them so we're left with just an
  // outline. Too bad we can't do this with gfx api's.
  //
  // At the end, we are left with an outline of the region in global coordinates.
  if ( geckoRegion ) {
    RgnHandle dragRegion = nsnull;
    geckoRegion->GetNativeRegion((void*&)dragRegion);
    if ( dragRegion && ioDragRgn ) {
      ::CopyRgn ( dragRegion, ioDragRgn );
      ::InsetRgn ( ioDragRgn, 1, 1 );
      ::DiffRgn ( dragRegion, ioDragRgn, ioDragRgn ); 
      
      // now shift the region into global coordinates.
      Point offsetFromLocalToGlobal = { 0, 0 };
      ::LocalToGlobal ( &offsetFromLocalToGlobal );
      ::OffsetRgn ( ioDragRgn, offsetFromLocalToGlobal.h, offsetFromLocalToGlobal.v );
    }
  }
  else {
    PRBool useRectFromFrame = PR_FALSE;
    
    // no region provided, let's try to use the dom node to get the frame. Pick a 
    // silly default in case we can't get it.
    Point currMouse;
    ::GetMouse(&currMouse);
    Rect frameRect = { currMouse.v, currMouse.h, currMouse.v + 25, currMouse.h + 100 };
    if ( inNode )
      useRectFromFrame = ComputeGlobalRectFromFrame ( inNode, frameRect );
    else
      NS_WARNING ( "Can't find anything to get a drag rect from. I'm dyin' out here!" );

    if ( ioDragRgn ) {
      RgnHandle frameRgn = ::NewRgn();
      if ( frameRgn ) {
        ::RectRgn ( frameRgn, &frameRect );
        ::CopyRgn ( frameRgn, ioDragRgn );
        ::InsetRgn ( ioDragRgn, 1, 1 );
        ::DiffRgn ( frameRgn, ioDragRgn, ioDragRgn );
        
        ::DisposeRgn ( frameRgn );
      }
    }
    
    // if we couldn't find the exact frame coordinates, then we need to alert people that
    // they shouldn't use this as the basis of SetDragImage()
    retVal = useRectFromFrame;
  }

  return retVal;
  
} // BuildDragRegion

Here is the call graph for this function:

static nsEventStatus PR_CALLBACK nsDragService::Callback ( nsGUIEvent event) [static, protected]
PRBool nsDragService::ComputeGlobalRectFromFrame ( nsIDOMNode aDOMNode,
Rect &  outScreenRect 
) [private]

Definition at line 136 of file nsDragService.cpp.

{
  NS_ASSERTION ( aDOMNode, "Oopps, no DOM node" );

// this isn't so much of an issue as long as we're just dragging around outlines,
// but it is when we are showing the text being drawn. Comment it out for now
// but leave it around when we turn this all back on (pinkerton).
#if USE_TRANSLUCENT_DRAGGING && defined(MOZ_XUL)
  // until bug 41237 is fixed, only do translucent dragging if the drag is in
  // the chrome or it's a link.
  nsCOMPtr<nsIContent> content = do_QueryInterface(aDOMNode);
  if (!content || !content->IsContentOfType(nsIContent::eXUL)) {
    // the link node is the parent of the node we have (which is probably text or image).
    nsCOMPtr<nsIDOMNode> parent;
    aDOMNode->GetParentNode ( getter_AddRefs(parent) );
    if ( parent ) {
      nsAutoString localName;
      parent->GetLocalName ( localName );
      if ( ! localName.EqualsLiteral("A") )
        return PR_FALSE;
    }
    else
      return FALSE;
  }
#endif
  
  outScreenRect.left = outScreenRect.right = outScreenRect.top = outScreenRect.bottom = 0;

  // Get the frame for this content node (note: frames are not refcounted)
  nsIFrame *aFrame = nsnull;
  nsCOMPtr<nsPresContext> presContext;
  GetFrameFromNode ( aDOMNode, &aFrame, getter_AddRefs(presContext) );
  if ( !aFrame || !presContext )
    return PR_FALSE;
  
  //
  // Now that we have the frame, we have to convert its coordinates into global screen
  // coordinates.
  //
  
  nsRect rect = aFrame->GetRect();

  // Find offset from our view
       nsIView *containingView = nsnull;
       nsPoint       viewOffset(0,0);
       aFrame->GetOffsetFromView(viewOffset, &containingView);
  NS_ASSERTION(containingView, "No containing view!");
  if ( !containingView )
    return PR_FALSE;

  // get the widget associated with the containing view. 
  nsPoint widgetOffset;
  nsIWidget* aWidget = containingView->GetNearestWidget ( &widgetOffset );

  float t2p = 1.0;
  t2p = presContext->TwipsToPixels();

  // Shift our offset rect by offset into our view, and
  // the view's offset to the closest widget. Then convert that to global coordinates.
  // Recall that WidgetToScreen() will give us the global coordinates of the rectangle we 
  // give it, but it expects  everything to be in pixels.
  nsRect screenOffset;                                
  screenOffset.MoveBy ( NSTwipsToIntPixels(widgetOffset.x + viewOffset.x, t2p),
                        NSTwipsToIntPixels(widgetOffset.y + viewOffset.y, t2p) );
  aWidget->WidgetToScreen ( screenOffset, screenOffset );

  // stash it all in a mac rect
  outScreenRect.left = screenOffset.x;
  outScreenRect.top = screenOffset.y;
  outScreenRect.right = outScreenRect.left + NSTwipsToIntPixels(rect.width, t2p);
  outScreenRect.bottom = outScreenRect.top + NSTwipsToIntPixels(rect.height, t2p);
            
  return PR_TRUE;
} // ComputeGlobalRectFromFrame

Here is the call graph for this function:

Here is the caller graph for this function:

void nsDragService::CreateDragCursor ( PRUint32  aActionType) [private]

Definition at line 266 of file nsDragService.cpp.

{
  if (sWindow == None) {
    Pixmap aPixmap;
    Pixmap aShapeMask;
    XSetWindowAttributes wattr;
    unsigned long wattr_mask;
    XWMHints wmHints;
    int depth;
    Screen *screen = xxlib_rgb_get_screen(sXlibRgbHandle);
    int screennum = XScreenNumberOfScreen(screen);

    wattr.override_redirect = True;
    wattr.background_pixel  = XWhitePixel(sDisplay, screennum);
    wattr.border_pixel      = XBlackPixel(sDisplay, screennum);
    wattr.colormap          = xxlib_rgb_get_cmap(sXlibRgbHandle);
    wattr_mask = CWOverrideRedirect | CWBorderPixel | CWBackPixel;
    if (wattr.colormap)
      wattr_mask |= CWColormap;
    
    depth = xxlib_rgb_get_depth(sXlibRgbHandle);
    
    /* make a window off-screen at -64, -64 */
    sWindow = XCreateWindow(sDisplay, XRootWindowOfScreen(screen),
                            -64, -64, 32, 32, 0, depth,
                            InputOutput, xxlib_rgb_get_visual(sXlibRgbHandle),
                            wattr_mask, &wattr);
    
    aPixmap = XCreatePixmapFromBitmapData(sDisplay, sWindow,
                                          (char *)drag_bitmap,
                                          32, 32, 0x0, 0xffffffff, depth);

    aShapeMask = XCreatePixmapFromBitmapData(sDisplay, sWindow,
                                             (char *)drag_mask,
                                             32, 32, 0xffffffff, 0x0, 1);

    wmHints.flags = StateHint;
    wmHints.initial_state = NormalState;
    XSetWMProperties(sDisplay, sWindow, nsnull, nsnull, nsnull, 0, nsnull,
                     &wmHints, nsnull);
    XSetTransientForHint(sDisplay, sWindow, sWindow);
    XShapeCombineMask(sDisplay, sWindow, ShapeClip, 0, 0, 
                      aShapeMask, ShapeSet);
    XShapeCombineMask(sDisplay, sWindow, ShapeBounding, 0, 0,
                      aShapeMask, ShapeSet);
    XSetWindowBackgroundPixmap(sDisplay, sWindow, aPixmap);
    XMapWindow(sDisplay, sWindow);
  }
}

Here is the call graph for this function:

BMessage * nsDragService::CreateDragMessage ( ) [private]

Definition at line 577 of file nsDragService.cpp.

{
    PR_LOG(sDragLm, PR_LOG_DEBUG, ("nsDragService::GetInitialDragMessage"));
    if (nsnull == mSourceDataItems)
        return NULL;
    
    unsigned int numDragItems = 0;
    mSourceDataItems->Count(&numDragItems);
    
    BMessage * returnMsg = new BMessage(B_SIMPLE_DATA);
    
    returnMsg->AddString("be:originator", "BeZilla");
    returnMsg->AddString("be:clip_name","BeZilla Drag Item");
  
    if (mDragAction & DRAGDROP_ACTION_COPY)
        returnMsg->AddInt32("be:actions",B_COPY_TARGET);
    if (mDragAction & DRAGDROP_ACTION_MOVE)
        returnMsg->AddInt32("be:actions",B_MOVE_TARGET);
    if (mDragAction & DRAGDROP_ACTION_LINK)
        returnMsg->AddInt32("be:actions",B_LINK_TARGET);
  
    // Check to see if we're dragging > 1 item.  If we are then we use
    // an internal only type.
    if (numDragItems > 1)
    {
        PR_LOG(sDragLm, PR_LOG_DEBUG, ("nsDragService:: Dragging a list of items ..."));
//        returnMsg->AddString("be:types", gMimeListType);
//        returnMsg->AddString("be:types", B_FILE_MIME_TYPE);
//        returnMsg->AddString("be:filetypes", gMimeListType);
//        returnMsg->AddString("be:type_descriptions", gMimeListType);        
        return returnMsg;
    }

    PRBool addedType = PR_FALSE;

    nsCOMPtr<nsISupports> genericItem;
    nsCOMPtr <nsISupportsArray> flavorList;
    PRUint32 numFlavors;
    nsCOMPtr<nsISupports> genericWrapper;
    nsXPIDLCString flavorStr;

    for (unsigned int itemIndex = 0; itemIndex < numDragItems; ++itemIndex)
    {
        mSourceDataItems->GetElementAt(itemIndex, getter_AddRefs(genericItem));
        nsCOMPtr<nsITransferable> currItem (do_QueryInterface(genericItem));
        if (nsnull == currItem) 
            continue;

        currItem->FlavorsTransferableCanExport(getter_AddRefs(flavorList));
        if (nsnull == flavorList)
            continue;
        flavorList->Count( &numFlavors );
        for (PRUint32 flavorIndex = 0; flavorIndex < numFlavors ; ++flavorIndex )
        {
            flavorList->GetElementAt(flavorIndex, getter_AddRefs(genericWrapper));
            nsCOMPtr<nsISupportsCString> currentFlavor = do_QueryInterface(genericWrapper);
            if (nsnull == currentFlavor)
                continue;
            currentFlavor->ToString ( getter_Copies(flavorStr) );
            
            PR_LOG(sDragLm, PR_LOG_DEBUG, ("nsDragService:: Adding a flavor to our message: %s",flavorStr.get()));
            
            type_code aCode;
            if (B_OK == returnMsg->GetInfo(flavorStr.get(), &aCode))
                continue;
            returnMsg->AddString("be:types",flavorStr.get());
            
            //returnMsg->AddString("be:types", B_FILE_MIME_TYPE);
            returnMsg->AddString("be:filetypes",flavorStr.get());
            returnMsg->AddString("be:type_descriptions",flavorStr.get());
            
            addedType = PR_TRUE;            
            // Check to see if this is text/unicode.  If it is, add
            // text/plain since we automatically support text/plain if
            // we support text/unicode.
            //tqh: but this may cause duplicates?
            if (0 == strcmp(flavorStr, kUnicodeMime))
            {
                PR_LOG(sDragLm, PR_LOG_DEBUG, ("nsDragService:: Adding a TextMime for the UnicodeMime"));
                returnMsg->AddString("be:types",kTextMime);
                //returnMsg->AddString("be:types", B_FILE_MIME_TYPE);
                returnMsg->AddString("be:filetypes",kTextMime);
                returnMsg->AddString("be:type_descriptions",kTextMime);
            }
        }
    }
    
    if (addedType) {
        returnMsg->AddString("be:types", B_FILE_MIME_TYPE);
    }
    returnMsg->PrintToStream();
    // If we did not add a type, we can't drag
    NS_ASSERTION(addedType == PR_TRUE, "No flavor/mime in the drag message!");
    return returnMsg;

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsDragService::DragLeaveMsg ( PDRAGINFO  pdinfo,
PRUint32 dragFlags 
) [virtual]

Implements nsIDragSessionOS2.

Definition at line 965 of file nsDragService.cpp.

{
  if (!mDoingDrag || !dragFlags)
    return NS_ERROR_FAILURE;

  if (mSourceNode)
    *dragFlags = DND_DISPATCHEVENT | DND_EXITSESSION | DND_MOZDRAG;
  else
    *dragFlags = DND_DISPATCHEVENT | DND_EXITSESSION | DND_NATIVEDRAG;

  return NS_OK;
}
NS_IMETHODIMP nsDragService::DragOverMsg ( PDRAGINFO  pdinfo,
MRESULT &  mr,
PRUint32 dragFlags 
) [virtual]

Implements nsIDragSessionOS2.

Definition at line 778 of file nsDragService.cpp.

{
  nsresult  rv = NS_ERROR_FAILURE;

  if (!&mr || !dragFlags || !pdinfo || !DrgAccessDraginfo(pdinfo))
    return rv;

  *dragFlags = 0;
  mr = MRFROM2SHORT(DOR_NEVERDROP, 0);

    // examine the dragged item & "start" a drag session if OK;
    // also, signal the need for a dragenter event
  if (!mDoingDrag)
    if (NS_SUCCEEDED(NativeDragEnter(pdinfo)))
      *dragFlags |= DND_DISPATCHENTEREVENT;

    // if we're in a drag, set it up to be dispatched
  if (mDoingDrag) {
    SetCanDrop(PR_FALSE);
    switch (pdinfo->usOperation) {
      case DO_COPY:
        SetDragAction(DRAGDROP_ACTION_COPY);
        break;
      case DO_LINK:
        SetDragAction(DRAGDROP_ACTION_LINK);
        break;
      default:
        SetDragAction(DRAGDROP_ACTION_MOVE);
        break;
    }
    if (mSourceNode)
      *dragFlags |= DND_DISPATCHEVENT | DND_GETDRAGOVERRESULT | DND_MOZDRAG;
    else
      *dragFlags |= DND_DISPATCHEVENT | DND_GETDRAGOVERRESULT | DND_NATIVEDRAG;
    rv = NS_OK;
  }

  DrgFreeDraginfo(pdinfo);
  return rv;
}

Here is the call graph for this function:

pascal OSErr nsDragService::DragSendDataProc ( FlavorType  inFlavor,
void inRefCon,
ItemReference  theItemRef,
DragReference  inDragRef 
) [static, private]

Definition at line 773 of file nsDragService.cpp.

{
  OSErr retVal = noErr;
  nsDragService* dragService = NS_STATIC_CAST(nsDragService*, inRefCon);
  NS_ASSERTION ( dragService, "Refcon not set correctly for DragSendDataProc" );
  if (dragService) {
    void* data = nsnull;
    PRUint32 dataSize = 0;
    retVal = dragService->GetDataForFlavor(dragService->mDataItems, inDragRef, inItemRef, inFlavor, &data, &dataSize);
    if ( retVal == noErr ) {      
        if ((inFlavor & kPrivateFlavorMask) == kPrivateFlavorTag) {
          // Byte-swap private flavors if running translated
          nsCOMPtr<nsIMacUtils> macUtils =
           do_GetService("@mozilla.org/xpcom/mac-utils;1");
          PRBool isTranslated;
          if (macUtils &&
              NS_SUCCEEDED(macUtils->GetIsTranslated(&isTranslated)) &&
              isTranslated) {
            char* swappedData = (char*) nsMemory::Alloc(dataSize);
            if (!swappedData) {
              nsMemory::Free(data);
              return notEnoughMemoryErr;
            }
            else {
              swab(data, swappedData, dataSize);
              nsMemory::Free(data);
              data = swappedData;
            }
          }
        }
        // make the data accessable to the DragManager
        retVal = ::SetDragItemFlavorData ( inDragRef, inItemRef, inFlavor, data, dataSize, 0 );
        NS_ASSERTION ( retVal == noErr, "SDIFD failed in DragSendDataProc" );
    }
    if ( data )
      nsMemory::Free ( data );
  } // if valid refcon
  
  return retVal;
  
} // DragSendDataProc

Here is the call graph for this function:

NS_IMETHODIMP nsDragService::DropHelpMsg ( PDRAGINFO  pdinfo,
PRUint32 dragFlags 
) [virtual]

Implements nsIDragSessionOS2.

Definition at line 983 of file nsDragService.cpp.

{
  if (!mDoingDrag)
    return NS_ERROR_FAILURE;

  if (pdinfo && DrgAccessDraginfo(pdinfo)) {
    DrgDeleteDraginfoStrHandles(pdinfo);
    DrgFreeDraginfo(pdinfo);
  }

  if (!dragFlags)
    return NS_ERROR_FAILURE;

  if (mSourceNode)
    *dragFlags = DND_DISPATCHEVENT | DND_EXITSESSION | DND_MOZDRAG;
  else
    *dragFlags = DND_DISPATCHEVENT | DND_EXITSESSION | DND_NATIVEDRAG;

  return NS_OK;
}
NS_IMETHODIMP nsDragService::DropMsg ( PDRAGINFO  pdinfo,
HWND  hwnd,
PRUint32 dragFlags 
) [virtual]

Implements nsIDragSessionOS2.

Definition at line 1039 of file nsDragService.cpp.

{
  if (!mDoingDrag || !dragFlags || !pdinfo || !DrgAccessDraginfo(pdinfo))
    return NS_ERROR_FAILURE;

  switch (pdinfo->usOperation) {
    case DO_MOVE:
      SetDragAction(DRAGDROP_ACTION_MOVE);
      break;
    case DO_COPY:
      SetDragAction(DRAGDROP_ACTION_COPY);
      break;
    case DO_LINK:
      SetDragAction(DRAGDROP_ACTION_LINK);
      break;
    default:  // avoid "moving" (i.e. deleting) native text/objects
      if (mSourceNode)
        SetDragAction(DRAGDROP_ACTION_MOVE);
      else
        SetDragAction(DRAGDROP_ACTION_COPY);
      break;
  }

    // if this is a native drag, move the source data to a transferable;
    // request rendering if needed
  nsresult rv = NS_OK;
  PRBool rendering = PR_FALSE;
  if (!mSourceNode)
    rv = NativeDrop( pdinfo, hwnd, &rendering);

    // note: NativeDrop() sends an end-conversation msg to native
    // sources but nothing sends them to Mozilla - however, Mozilla
    // (i.e. nsDragService) doesn't need them, so...

    // if rendering, the action flags are off because we don't want
    // the client to do anything yet;  the status flags are off because
    // we'll be exiting d&d mode before the next screen update occurs
  if (rendering)
    *dragFlags = 0;
  else {
    // otherwise, set the flags & free the native drag structures

    *dragFlags = DND_EXITSESSION;
    if (NS_SUCCEEDED(rv))
      if (mSourceNode)
        *dragFlags |= DND_DISPATCHEVENT | DND_INDROP | DND_MOZDRAG;
      else
        *dragFlags |= DND_DISPATCHEVENT | DND_INDROP | DND_NATIVEDRAG;

    DrgDeleteDraginfoStrHandles(pdinfo);
    DrgFreeDraginfo(pdinfo);
    rv = NS_OK;
  }

  return rv;
}

Here is the call graph for this function:

Definition at line 346 of file nsDragService.cpp.

{
    PR_LOG(sDragLm, PR_LOG_DEBUG, ("nsDragService::EndDragSession()"));
    //Don't reset drag info, keep it until there is a new drag, in case a negotiated drag'n'drop wants the info.
    //We need the draginfo as we are ending starting the dragsession
    //on entering/exiting different views (nsWindows) now.
    //That way the dragsession is always ended when we go outside mozilla windows, but we do throw away the 
    // mSourceDocument and mSourceNode. We do hold on to the nsTransferable if it was a internal drag. 
    //ResetDragInfo();
    return nsBaseDragService::EndDragSession();

Here is the caller graph for this function:

Tells the Drag Service to end a drag session.

This is called when an external drag occurs

Implements nsIDragSessionOS2.

Definition at line 1009 of file nsDragService.cpp.

{
  if (!mDoingDrag)
    return NS_ERROR_FAILURE;

  if (!mSourceNode) {
    mSourceDataItems = 0;
    mDoingDrag = FALSE;

      // if we created a temp file, delete it
    if (gTempFile) {
      DosDelete(gTempFile);
      nsMemory::Free(gTempFile);
      gTempFile = 0;
    }
  }

  if (!dragFlags)
    return NS_ERROR_FAILURE;
  *dragFlags = 0;

  return NS_OK;
}

Here is the caller graph for this function:

nsresult nsDragService::ExtractDataFromOS ( DragReference  inDragRef,
ItemReference  inItemRef,
ResType  inFlavor,
void **  outBuffer,
PRUint32 outBuffSize 
) [private]

Definition at line 1088 of file nsDragService.cpp.

{
  if ( !outBuffer || !outBuffSize || !inFlavor )
    return NS_ERROR_FAILURE;

  nsresult retval = NS_OK;
  char* buff = nsnull;
  Size buffSize = 0;
  OSErr err = ::GetFlavorDataSize ( inDragRef, inItemRef, inFlavor, &buffSize );
  if ( !err && buffSize > 0 ) {
    buff = NS_REINTERPRET_CAST(char*, nsMemory::Alloc(buffSize + 1));
    if ( buff ) {         
      err = ::GetFlavorData ( inDragRef, inItemRef, inFlavor, buff, &buffSize, 0 );
      if (err == noErr) {
        if ((inFlavor & kPrivateFlavorMask) == kPrivateFlavorTag) {
          // Byte-swap private flavors if running translated
          nsCOMPtr<nsIMacUtils> macUtils =
           do_GetService("@mozilla.org/xpcom/mac-utils;1");
          PRBool isTranslated;
          if (macUtils &&
              NS_SUCCEEDED(macUtils->GetIsTranslated(&isTranslated)) &&
              isTranslated) {
            char* swappedData = (char*) nsMemory::Alloc(buffSize);
            if (!swappedData)
              retval = NS_ERROR_OUT_OF_MEMORY;
            else {
              swab(buff, swappedData, buffSize);
              nsMemory::Free(buff);
              buff = swappedData;
            }
          }
        }
      }
      else {
        #ifdef NS_DEBUG
          printf("nsDragService: Error getting data out of drag manager, #%ld\n", err);
        #endif
        retval = NS_ERROR_FAILURE;
      }
    }
    else
      retval = NS_ERROR_FAILURE;
  }

  if ( NS_FAILED(retval) ) {
    if ( buff )
      nsMemory::Free(buff);
  }
  else {
    *outBuffer = buff;
    *outBuffSize = buffSize;
  }
  return retval;

} // ExtractDataFromOS

Here is the call graph for this function:

Here is the caller graph for this function:

const char * nsDragService::FlavorToBeMime ( const char *  flavor) [static, private]

Definition at line 760 of file nsDragService.cpp.

{
    //text/plain ok
    //text/unicode -> text/plain
    if (0 == strcmp(flavor,kUnicodeMime)) return kTextMime;    
    //text/html ok
    //AOLMAIL ignore!!     
    //image/png ok
    //image/jpg
    if (0 == strcmp(flavor,kJPEGImageMime)) return "image/jpeg";
    //image/gif ok
    //application/x-moz-file
    if (0 == strcmp(flavor,kFileMime)) return "application/octet-stream";
    //text/x-moz-url (only support this as a filetype (Be bookmark))
    if (0 == strcmp(flavor,kURLMime)) return "application/x-vnd.Be-bookmark";
    //text/x-moz-url-data - we need to read data to find out what type of URL.
    //text/x-moz-url-desc - a url-description (same as title?)
    //kNativeImageMime - don't support as BeOS image
    //kNativeHTMLMime - don't support on BeOS side
    //kFilePromiseURLMime
    //kFilePromiseDestFilename
    //kFilePromiseMime
    //kFilePromiseDirectoryMime
    
//    if (0==strcmp(flavor,kUnicodeMime))

Definition at line 382 of file nsDragService.cpp.

{
    PR_LOG(sDragLm, PR_LOG_DEBUG, ("nsDragService::GetCanDrop()"));
    return nsBaseDragService::GetCanDrop(aCanDrop);

Here is the caller graph for this function:

Returns the current Drag Session.

Definition at line 157 of file nsDragService.cpp.

{
  if (!aSession)
    return NS_ERROR_FAILURE;

  if (!mDragging || mSuppressLevel) {
    *aSession = nsnull;
    return NS_OK;
  }

  *aSession = (nsIDragSession *)this;
  NS_ADDREF(*aSession);
  return NS_OK;
}

Here is the call graph for this function:

NS_IMETHOD nsDragService::GetData ( nsITransferable aTransferable,
PRUint32  anItem 
)
NS_IMETHOD nsDragService::GetData ( nsITransferable aTransferable,
PRUint32  anItem 
)
NS_IMETHOD nsDragService::GetData ( nsITransferable aTransferable,
PRUint32  aItemIndex 
)
NS_IMETHOD nsDragService::GetData ( nsITransferable aTransferable,
PRUint32  aItemIndex 
)
NS_IMETHODIMP nsDragService::GetData ( nsITransferable aTransferable,
PRUint32  aItemIndex 
)

Definition at line 429 of file nsDragService.cpp.

{
    PR_LOG(sDragLm, PR_LOG_DEBUG, ("nsDragService::GetData %d", aItemIndex));

    if (nsnull==mDragMessage)
        return NS_ERROR_INVALID_ARG;

    // get flavor list that includes all acceptable flavors (including
    // ones obtained through conversion). Flavors are nsISupportsStrings
    // so that they can be seen from JS.
    nsresult rv = NS_ERROR_FAILURE;
    nsCOMPtr<nsISupportsArray> flavorList;
    rv = aTransferable->FlavorsTransferableCanImport(getter_AddRefs(flavorList));
    if (NS_FAILED(rv))
        return rv;

    // count the number of flavors
    PRUint32 cnt;
    flavorList->Count (&cnt);

    nsCOMPtr<nsISupports> genericWrapper;
    nsCOMPtr<nsISupportsCString> currentFlavor;
    nsXPIDLCString flavorStr;
    nsCOMPtr<nsISupports> genericItem;   
    nsCOMPtr<nsISupports> data;
    PRUint32 tmpDataLen = 0;
    for (unsigned int i= 0; i < cnt; ++i )
    {
        flavorList->GetElementAt(i, getter_AddRefs(genericWrapper));
        currentFlavor = do_QueryInterface(genericWrapper);
        if (!currentFlavor)
            continue;
        currentFlavor->ToString(getter_Copies(flavorStr));
        
        PR_LOG(sDragLm, PR_LOG_DEBUG, ("tnsDragService::GetData trying to get transfer data for %s",
                        (const char *)flavorStr));
                        
        if (IsInternalDrag(mDragMessage))
        {
            mSourceDataItems->GetElementAt(aItemIndex, getter_AddRefs(genericItem));
            nsCOMPtr<nsITransferable> item (do_QueryInterface(genericItem));
            if (!item)
                continue;
            rv = item->GetTransferData(flavorStr, getter_AddRefs(data), &tmpDataLen);
            if (NS_FAILED(rv))
                continue;
            PR_LOG(sDragLm, PR_LOG_DEBUG, ("tnsDragService::GetData setting data."));
            return aTransferable->SetTransferData(flavorStr, data, tmpDataLen);
        } 
        else
        {
            //Check if transfer message is simple_data or older type of DND
            //Check if message has data else continue
            //Negotiate for data (if possible) or get data
               //set and return
        }
    }
    PR_LOG(sDragLm, PR_LOG_DEBUG, ("tnsDragService::GetData failed"));
    return NS_ERROR_FAILURE;

Here is the call graph for this function:

NS_IMETHOD nsDragService::GetData ( nsITransferable aTransferable,
PRUint32  aItemIndex 
)
NS_IMETHOD nsDragService::GetData ( nsITransferable aTransferable,
PRUint32  anItemIndex 
)
NS_IMETHOD nsDragService::GetData ( nsITransferable aTransferable,
PRUint32  aItemIndex 
)
NS_IMETHOD nsDragService::GetData ( nsITransferable aTransferable,
PRUint32  aItemIndex 
)
void nsIDragSession::getData ( in nsITransferable  aTransferable,
in unsigned long  aItemIndex 
) [inherited]

Get data from a Drag&Drop.

Can be called while the drag is in process or after the drop has completed.

Parameters:
aTransferablethe transferable for the data to be put into
aItemIndexwhich of multiple drag items, zero-based
OSErr nsDragService::GetDataForFlavor ( nsISupportsArray inDragItems,
DragReference  inDragRef,
unsigned int  inItemIndex,
FlavorType  inFlavor,
void **  outData,
unsigned int outSize 
) [private]

Definition at line 831 of file nsDragService.cpp.

{
  if ( !inDragItems || !inDragRef )
    return paramErr;
    
  *outData = nsnull;
  *outDataSize = 0;

  OSErr retVal = noErr;
  nsresult rv;
  
  // (assumes that the items were placed into the transferable as nsITranferable*'s, not nsISupports*'s.)
  nsCOMPtr<nsISupports> genericItem;
  inDragItems->GetElementAt(inItemIndex, getter_AddRefs(genericItem));
  nsCOMPtr<nsITransferable> item(do_QueryInterface(genericItem));
  if (!item) return cantGetFlavorErr;
    
    // create a mime mapper to help us out based on data in a special flavor for this item.
  char* mappings = LookupMimeMappingsForItem(inDragRef, inItemIndex);
  nsMimeMapperMac theMapper(mappings);

  nsCAutoString mimeFlavor;
  theMapper.MapMacOSTypeToMimeType(inFlavor, mimeFlavor);
  nsMemory::Free(mappings);
  
  // if someone was asking for text/plain, lookup unicode instead so we can convert it.
  PRBool needToDoConversionToPlainText = PR_FALSE;
  const char* actualFlavor = mimeFlavor.get();
  if ( strcmp(mimeFlavor.get(), kTextMime) == 0 || inFlavor == 'styl' )
  {
    actualFlavor = kUnicodeMime;
    needToDoConversionToPlainText = PR_TRUE;
  }
  else if (strcmp(actualFlavor, kURLDataMime) == 0)
  {
    needToDoConversionToPlainText = PR_TRUE;
  }
  else if (strcmp(actualFlavor, kURLDescriptionMime) == 0)
  {
    needToDoConversionToPlainText = PR_TRUE;
  }
  else if (strcmp(actualFlavor, kFilePromiseMime) == 0)
  {
    /*  Here's how file dragging works:
    
        Drag code adds a kFilePromiseMime flavor to the transferable, with an
        nsIFlavorDataProvider.
        It also adds a kFilePromiseURLMime flavor, with a string containing the source
        url.
    
        We map that to the OS drag flavor kDragFlavorTypePromiseHFS, which promises
        the flavor kDragPromisedFlavor. The OS asks for kDragPromisedFlavor, and we
        map that back to kFilePromiseMime.
        
        When asked for kFilePromiseMime data (here), we figure out the drop location from
        the OS, and set that as an nsILocalFile on the kFilePromiseDirectoryMime flavor. We then
        call GetTransferData() for the kFilePromiseMime flavor, which triggers
        the nsIFlavorDataProvider to do the save.
    */

    nsCOMPtr<nsILocalFile> dropDirectory;
    OSErr err = GetHFSPromiseDropDirectory(inDragRef, inItemIndex, inFlavor, getter_AddRefs(dropDirectory));
    if (err != noErr) return err;
    
    // now add a flavor to the transferable
    nsCOMPtr<nsISupports> localFileISupports = do_QueryInterface(dropDirectory);
    item->SetTransferData(kFilePromiseDirectoryMime, localFileISupports, sizeof(nsILocalFile*));
    
    // now request the kFilePromiseMime data, which will invoke the data provider
    // If successful, the returned data is a reference to the resulting file.
    nsCOMPtr<nsISupports> fileDataPrimitive;
    PRUint32 dataSize = 0;
    rv = item->GetTransferData(kFilePromiseMime, getter_AddRefs(fileDataPrimitive), &dataSize);
    if (NS_FAILED(rv)) return cantGetFlavorErr;
    
    // if we successfully saved, tell the Drag Manager
    nsCOMPtr<nsILocalFile> resultFile = do_QueryInterface(fileDataPrimitive);
    if (resultFile)
      return SetDropFileInDrag(inDragRef, inItemIndex, inFlavor, resultFile);
    
    // something went wrong.
    return cantGetFlavorErr;
  }
  else if (strcmp(actualFlavor, kNativeImageMime) == 0)
  {
    PRUint32 dataSize = 0;
    nsCOMPtr<nsISupports> transferSupports;
    rv = item->GetTransferData(actualFlavor, getter_AddRefs(transferSupports), &dataSize);
    if (NS_FAILED(rv)) return cantGetFlavorErr;

    nsCOMPtr<nsISupportsInterfacePointer> ptrPrimitive(do_QueryInterface(transferSupports));
    if (!ptrPrimitive) return cantGetFlavorErr; 
    
    nsCOMPtr<nsISupports> primitiveData;
    ptrPrimitive->GetData(getter_AddRefs(primitiveData));
    nsCOMPtr<nsIImageMac> image = do_QueryInterface(primitiveData);
    if (!image) return cantGetFlavorErr; 
      
    PicHandle picture = nsnull;
    image->ConvertToPICT(&picture);
    if (!picture) return cantGetFlavorErr; 

    PRInt32 pictSize = ::GetHandleSize((Handle)picture);
    char* pictData = nsnull;
    if (pictSize > 0)
      pictData = (char*)nsMemory::Alloc(pictSize);
    if (pictData) {
      ::BlockMoveData(*picture, pictData, pictSize);    // doesn't move memory
      *outData = (void*)pictData;
      *outDataSize = pictSize;
      retVal = noErr;
    }
    else
      retVal = cantGetFlavorErr;

    ::KillPicture(picture);
    return retVal;
  }
    
  nsCOMPtr<nsISupports> data;
  if (NS_SUCCEEDED(item->GetTransferData(actualFlavor, getter_AddRefs(data), outDataSize)))
  {
    nsPrimitiveHelpers::CreateDataFromPrimitive ( actualFlavor, data, outData, *outDataSize );
        
    // Convert unix to mac linebreaks, since mac linebreaks are required for clipboard compatibility.
    // I'm making the assumption here that the substitution will be entirely in-place, since both
    // types of line breaks are 1-byte.
    PRUnichar* castedUnicode = NS_REINTERPRET_CAST(PRUnichar*, *outData);
    nsLinebreakConverter::ConvertUnicharLineBreaksInSitu(&castedUnicode,
                                                         nsLinebreakConverter::eLinebreakUnix,
                                                         nsLinebreakConverter::eLinebreakMac,
                                                         *outDataSize / sizeof(PRUnichar), nsnull);

    // if required, do the extra work to convert unicode to plain text and replace the output
    // values with the plain text.
    if ( needToDoConversionToPlainText ) {
      char* plainTextData = nsnull;
      PRInt32 plainTextLen = 0;
      nsresult rv =
      nsPrimitiveHelpers::ConvertUnicodeToPlatformPlainText ( castedUnicode, *outDataSize / 2, &plainTextData, &plainTextLen );

      ScriptCodeRun *scriptCodeRuns = nsnull;
      PRInt32 scriptRunOutLen;

      // if characters are not mapped from Unicode then try native API to convert to 
      // available script
      if (rv == NS_ERROR_UENC_NOMAPPING) {
        if (plainTextData) {
          nsMemory::Free(plainTextData);
          plainTextData = nsnull;
        }
        rv = nsMacNativeUnicodeConverter::ConvertUnicodetoScript(castedUnicode, 
                                                                 *outDataSize / sizeof(PRUnichar),
                                                                 &plainTextData, 
                                                                 &plainTextLen,
                                                                 &scriptCodeRuns,
                                                                 &scriptRunOutLen);
      }
      else if (NS_SUCCEEDED(rv)) {
        // create a single run with the default system script
        scriptCodeRuns = NS_REINTERPRET_CAST(ScriptCodeRun*,
                                             nsMemory::Alloc(sizeof(ScriptCodeRun)));
        if (scriptCodeRuns) {
          scriptCodeRuns[0].offset = 0;
          scriptCodeRuns[0].script = (ScriptCode) ::GetScriptManagerVariable(smSysScript);
          scriptRunOutLen = 1;
        }
      }
      
      if ( plainTextData && *outData ) {
        nsMemory::Free(*outData);
        *outData = nsnull;
        *outDataSize = 0;
        
        if (inFlavor != 'styl') {
          *outData = plainTextData;
          *outDataSize = plainTextLen;
        }
        else {
          nsMemory::Free(plainTextData);  // discard 'TEXT'
          
          char *stylData;
          PRInt32 stylLen;
          // create 'styl' from the script runs
          if (scriptCodeRuns) {
            rv = CreateStylFromScriptRuns(scriptCodeRuns,
                                               scriptRunOutLen,
                                               &stylData,
                                               &stylLen);
            if (NS_SUCCEEDED(rv)) {
              *outData = stylData;
              *outDataSize = stylLen;
            }
          }
        }
      }
      else
        retVal = cantGetFlavorErr;
      if (scriptCodeRuns)
        nsMemory::Free(scriptCodeRuns);
    }
  }

  return retVal;

} // GetDataForFlavor

Here is the call graph for this function:

Here is the caller graph for this function:

nsDataObjCollection * nsDragService::GetDataObjCollection ( IDataObject *  aDataObj) [protected]

Definition at line 227 of file nsDragService.cpp.

{
  nsDataObjCollection * dataObjCol = nsnull;
  if (aDataObj) {
    nsIDataObjCollection* dataObj;
    if (aDataObj->QueryInterface(IID_IDataObjCollection,
                                 (void**)&dataObj) == S_OK) {
      dataObjCol = NS_STATIC_CAST(nsDataObjCollection*, aDataObj);
      dataObj->Release();
    }
  }

  return dataObjCol;
}
NS_IMETHODIMP nsDragService::GetDragoverResult ( MRESULT &  mr) [virtual]

Implements nsIDragSessionOS2.

Definition at line 919 of file nsDragService.cpp.

{
  nsresult  rv = NS_ERROR_FAILURE;
  if (!&mr)
    return rv;

  if (mDoingDrag) {

    PRBool canDrop = PR_FALSE;
    USHORT usDrop;
    GetCanDrop(&canDrop);
    if (canDrop)
      usDrop = DOR_DROP;
    else
      usDrop = DOR_NODROP;

    PRUint32 action;
    USHORT   usOp;
    GetDragAction(&action);
    if (action & DRAGDROP_ACTION_COPY)
      usOp = DO_COPY;
    else
    if (action & DRAGDROP_ACTION_LINK)
      usOp = DO_LINK;
    else {
      if (mSourceNode)
        usOp = DO_MOVE;
      else
        usOp = DO_UNKNOWN+1;
      if (action == DRAGDROP_ACTION_NONE)
        usDrop = DOR_NODROP;
    }

    mr = MRFROM2SHORT(usDrop, usOp);
    rv = NS_OK;
  }
  else
    mr = MRFROM2SHORT(DOR_NEVERDROP, 0);

  return rv;
}

Here is the call graph for this function:

void nsBaseDragService::GetFrameFromNode ( nsIDOMNode inNode,
nsIFrame **  outFrame,
nsPresContext **  outContext 
) [protected, virtual, inherited]

Definition at line 289 of file nsBaseDragService.cpp.

{
  *outFrame = nsnull;
  *outContext = nsnull;
  if (!inNode || !outContext)
    return;

  nsCOMPtr<nsIContent> contentNode = do_QueryInterface(inNode);
  if (contentNode) {
    nsIDocument* doc = contentNode->GetDocument();
    if (doc) {
      nsIPresShell *presShell = doc->GetShellAt(0);
      if (presShell) {
        NS_IF_ADDREF(*outContext = presShell->GetPresContext());
        presShell->GetPrimaryFrameFor(contentNode, outFrame);
        NS_ASSERTION(*outFrame, "Can't get frame for this dom node");
      }
    }
  }

} // GetFrameFromNode

Here is the call graph for this function:

Here is the caller graph for this function:

OSErr nsDragService::GetHFSPromiseDropDirectory ( DragReference  inDragRef,
unsigned int  inItemIndex,
FlavorType  inFlavor,
nsILocalFile **  outDir 
) [private]

Definition at line 1205 of file nsDragService.cpp.

{
  // get the promise data
  PromiseHFSFlavor promiseData;
  Size dataSize = sizeof(promiseData);
  OSErr err = ::GetFlavorData(inDragRef, inItemIndex, kDragFlavorTypePromiseHFS, &promiseData, &dataSize, 0);
  if (err != noErr) return err;
  
  FSSpec dropLocation;
  err = GetDropDirectory(inDragRef, &dropLocation);
  if (err != noErr) return err;
  
  nsCOMPtr<nsILocalFileMac> dropFolderSpec;
  nsresult rv = NS_NewLocalFileWithFSSpec(&dropLocation, PR_FALSE, getter_AddRefs(dropFolderSpec));
  if (NS_FAILED(rv)) return fnfErr;

  CallQueryInterface(dropFolderSpec, outDir);
  return noErr;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 396 of file nsDragService.cpp.

{
    PR_LOG(sDragLm, PR_LOG_DEBUG, ("nsDragService::GetNumDropItems()"));
    if (nsnull == mDragMessage)
    {
        *aNumItems = 0;
        PR_LOG(sDragLm, PR_LOG_DEBUG, ("nsDragService::GetNumDropItems(): WARNING! No dragmessage"));
        return NS_OK;
    } 
    // Did we start this drag?
    if (IsInternalDrag(mDragMessage))
        mSourceDataItems->Count(aNumItems);
    else
        // The only thing native that I can think of that may have multiple items
        // would be file references, DND-docs don't say anything about multiple items.
        *aNumItems = 1;


    PR_LOG(sDragLm, PR_LOG_DEBUG, ("nsDragService::GetNumDropItems():%d", *aNumItems));
    return NS_OK;

Here is the call graph for this function:

GtkTargetList * nsDragService::GetSourceList ( void  ) [private]

Definition at line 820 of file nsDragService.cpp.

{
  if (!mSourceDataItems)
    return NULL;
  nsVoidArray targetArray;
  GtkTargetEntry *targets;
  GtkTargetList  *targetList = 0;
  PRUint32 targetCount = 0;
  unsigned int numDragItems = 0;

  mSourceDataItems->Count(&numDragItems);

  // Check to see if we're dragging > 1 item.
  if (numDragItems > 1) {
    // as the Xdnd protocol only supports a single item (or is it just
    // gtk's implementation?), we don't advertise all flavours listed
    // in the nsITransferable.

    // the application/x-moz-internal-item-list format, which preserves
    // all information for drags within the same mozilla instance.
    GdkAtom listAtom = gdk_atom_intern(gMimeListType, FALSE);
    GtkTargetEntry *listTarget = (GtkTargetEntry *)g_malloc(sizeof(GtkTargetEntry));
    listTarget->target = g_strdup(gMimeListType);
    listTarget->flags = 0;
    listTarget->info = listAtom;
    PR_LOG(sDragLm, PR_LOG_DEBUG, ("automatically adding target %s with id %ld\n", 
                                   listTarget->target, listAtom));
    targetArray.AppendElement(listTarget);

    // check what flavours are supported so we can decide what other
    // targets to advertise.
    nsCOMPtr<nsISupports> genericItem;
    mSourceDataItems->GetElementAt(0, getter_AddRefs(genericItem));
    nsCOMPtr<nsITransferable> currItem (do_QueryInterface(genericItem));

    if (currItem) {
      nsCOMPtr <nsISupportsArray> flavorList;
      currItem->FlavorsTransferableCanExport(getter_AddRefs(flavorList));
      if (flavorList) {
        PRUint32 numFlavors;
        flavorList->Count( &numFlavors );
        for (PRUint32 flavorIndex = 0; flavorIndex < numFlavors ;
             ++flavorIndex ) {
          nsCOMPtr<nsISupports> genericWrapper;
          flavorList->GetElementAt(flavorIndex, getter_AddRefs(genericWrapper));
          nsCOMPtr<nsISupportsCString> currentFlavor;
          currentFlavor = do_QueryInterface(genericWrapper);
          if (currentFlavor) {
            nsXPIDLCString flavorStr;
            currentFlavor->ToString ( getter_Copies(flavorStr) );

            // check if text/x-moz-url is supported.  If so, advertise
            // text/uri-list.
            if (strcmp(flavorStr, kURLMime) == 0) {
              listAtom = gdk_atom_intern(gTextUriListType, FALSE);
              listTarget = (GtkTargetEntry *)g_malloc(sizeof(GtkTargetEntry));
              listTarget->target = g_strdup(gTextUriListType);
              listTarget->flags = 0;
              listTarget->info = listAtom;
              PR_LOG(sDragLm, PR_LOG_DEBUG, ("automatically adding target %s with id %ld\n", 
                                             listTarget->target, listAtom));
              targetArray.AppendElement(listTarget);
            }

          }
        } // foreach flavor in item
      } // if valid flavor list
    } // if item is a transferable
  } else if (numDragItems == 1) {
    nsCOMPtr<nsISupports> genericItem;
    mSourceDataItems->GetElementAt(0, getter_AddRefs(genericItem));
    nsCOMPtr<nsITransferable> currItem (do_QueryInterface(genericItem));
    if (currItem) {
      nsCOMPtr <nsISupportsArray> flavorList;
      currItem->FlavorsTransferableCanExport(getter_AddRefs(flavorList));
      if (flavorList) {
        PRUint32 numFlavors;
        flavorList->Count( &numFlavors );
        for (PRUint32 flavorIndex = 0; flavorIndex < numFlavors ;
             ++flavorIndex ) {
          nsCOMPtr<nsISupports> genericWrapper;
          flavorList->GetElementAt(flavorIndex, getter_AddRefs(genericWrapper));
          nsCOMPtr<nsISupportsCString> currentFlavor;
          currentFlavor = do_QueryInterface(genericWrapper);
          if (currentFlavor) {
            nsXPIDLCString flavorStr;
            currentFlavor->ToString ( getter_Copies(flavorStr) );
            // get the atom
            GdkAtom atom = gdk_atom_intern(flavorStr, FALSE);
            GtkTargetEntry *target = (GtkTargetEntry *)g_malloc(sizeof(GtkTargetEntry));
            target->target = g_strdup(flavorStr);
            target->flags = 0;
            target->info = atom;
            PR_LOG(sDragLm, PR_LOG_DEBUG,
                   ("adding target %s with id %ld\n", target->target, atom));
            targetArray.AppendElement(target);
            // Check to see if this is text/unicode.  If it is, add
            // text/plain since we automatically support text/plain if
            // we support text/unicode.
            if (strcmp(flavorStr, kUnicodeMime) == 0) {
              // get the atom for the unicode string
              GdkAtom plainAtom = gdk_atom_intern(kTextMime, FALSE);
              GtkTargetEntry *plainTarget = (GtkTargetEntry *)g_malloc(sizeof(GtkTargetEntry));
              plainTarget->target = g_strdup(kTextMime);
              plainTarget->flags = 0;
              plainTarget->info = plainAtom;
              PR_LOG(sDragLm, PR_LOG_DEBUG, ("automatically adding target %s with id %ld\n", 
                                             plainTarget->target, plainAtom));
              targetArray.AppendElement(plainTarget);
            }
            // Check to see if this is the x-moz-url type.  If it is,
            // add _NETSCAPE_URL this is a type used by everybody.
            if (strcmp(flavorStr, kURLMime) == 0) {
              // get the atom name for it
              GdkAtom urlAtom = gdk_atom_intern(gMozUrlType, FALSE);
              GtkTargetEntry *urlTarget = (GtkTargetEntry *)g_malloc(sizeof(GtkTargetEntry));
              urlTarget->target = g_strdup(gMozUrlType);
              urlTarget->flags = 0;
              urlTarget->info = urlAtom;
              PR_LOG(sDragLm, PR_LOG_DEBUG, ("automatically adding target %s with id %ld\n",
                                             urlTarget->target, urlAtom));
              targetArray.AppendElement(urlTarget);
            }
          }
        } // foreach flavor in item
      } // if valid flavor list
    } // if item is a transferable
  } // if it is a single item drag

  // get all the elements that we created.
  targetCount = targetArray.Count();
  if (targetCount) {
    // allocate space to create the list of valid targets
    targets = (GtkTargetEntry *)g_malloc(sizeof(GtkTargetEntry) * targetCount);
    for (PRUint32 targetIndex = 0; targetIndex < targetCount; ++targetIndex) {
      GtkTargetEntry *disEntry = (GtkTargetEntry *)targetArray.ElementAt(targetIndex);
      // this is a string reference but it will be freed later.
      targets[targetIndex].target = disEntry->target;
      targets[targetIndex].flags = disEntry->flags;
      targets[targetIndex].info = disEntry->info;
    }
    targetList = gtk_target_list_new(targets, targetCount);
    // clean up the target list
    for (PRUint32 cleanIndex = 0; cleanIndex < targetCount; ++cleanIndex) {
      GtkTargetEntry *thisTarget = (GtkTargetEntry *)targetArray.ElementAt(cleanIndex);
      g_free(thisTarget->target);
      g_free(thisTarget);
    }
    g_free(targets);
  }

  return targetList;
}

Here is the call graph for this function:

GtkTargetList* nsDragService::GetSourceList ( void  ) [private]
void nsDragService::GetTargetDragData ( GdkAtom  aFlavor) [private]
void nsDragService::GetTargetDragData ( GdkAtom  aFlavor) [private]

Definition at line 782 of file nsDragService.cpp.

{
  gtk_grab_add(mHiddenWidget);
  PR_LOG(sDragLm, PR_LOG_DEBUG, ("getting data flavor %d\n", aFlavor));
  PR_LOG(sDragLm, PR_LOG_DEBUG, ("mLastWidget is %p and mLastContext is %p\n",
                                 mTargetWidget, mTargetDragContext));
  // reset our target data areas
  TargetResetData();
  gtk_drag_get_data(mTargetWidget, mTargetDragContext, aFlavor, mTargetTime);
  // Make sure to set the mDataReceived to PR_FALSE since we're about
  // to try to get the data.  It might have been left set to PR_TRUE
  // if this is another request in the same drag session where the
  // previous one failed.  However, there are cases where we can get
  // the data received signal before we get to this point so only set
  // it if there isn't any drag data.
  PR_LOG(sDragLm, PR_LOG_DEBUG, ("about to start inner iteration."));
  while (!mTargetDragDataReceived && mDoingDrag) {
    // XXX check the number of iterations...we could grab forever and
    // that would make me sad.
    PR_LOG(sDragLm, PR_LOG_DEBUG, ("doing iteration...\n"));
    gtk_main_iteration();
  }
  PR_LOG(sDragLm, PR_LOG_DEBUG, ("finished inner iteration\n"));
  gtk_grab_remove(mHiddenWidget);
}

Here is the call graph for this function:

nsresult nsDragService::GetUniTextTitle ( nsISupports *  aGenericData,
char **  aTargetName 
) [protected]

Definition at line 701 of file nsDragService.cpp.

{
    // get the string
  nsCOMPtr<nsISupportsString> strObject ( do_QueryInterface(aGenericData));
  if (!strObject)
    return NS_ERROR_FAILURE;

    // alloc a buffer to hold the unicode title text
  int bufsize = (MAXTITLELTH+1)*2;
  PRUnichar * buffer = (PRUnichar*)nsMemory::Alloc(bufsize);
  if (!buffer)
    return NS_ERROR_FAILURE;

  nsAutoString strData;
  strObject->GetData(strData);
  nsAutoString::const_iterator start, end;
  strData.BeginReading(start);
  strData.EndReading(end);

    // skip over leading non-alphanumerics
  for( ; start != end; ++start)
    if (UniQueryChar( *start, CT_ALNUM))
      break;

    // move alphanumerics into the buffer & replace contiguous
    // non-alnums with a single separator character
  int ctr, sep;
  for (ctr=0, sep=0; start != end && ctr < MAXTITLELTH; ++start) {
    if (UniQueryChar( *start, CT_ALNUM)) {
      buffer[ctr] = *start;
      ctr++;
      sep = 0;
    }
    else
      if (!sep) {
        buffer[ctr] = TITLESEPARATOR;
        ctr++;
        sep = 1;
      }
  }
    // eliminate trailing separators & lone characters
    // orphaned when the title is truncated
  if (sep)
    ctr--;
  if (ctr >= MAXTITLELTH - sep && buffer[ctr-2] == TITLESEPARATOR)
    ctr -= 2;
  buffer[ctr] = 0;

    // if we ended up with no alnums, call the result "text";
    // otherwise, do NLS conversion
  if (!ctr) {
    *aTargetName = ToNewCString(NS_LITERAL_CSTRING("text"));
    ctr = 1;
  }
  else
    ctr = UnicodeToCodepage( nsDependentString(buffer), aTargetName);

    // free our buffer, then exit
  nsMemory::Free(buffer);

  if (!ctr)
  return NS_ERROR_FAILURE;

  mSourceData = aGenericData;
  mMimeType = kUnicodeMime;
  return NS_OK;
}

Here is the call graph for this function:

nsresult nsDragService::GetUrlAndTitle ( nsISupports *  aGenericData,
char **  aTargetName 
) [protected]

Definition at line 600 of file nsDragService.cpp.

{
    // get the URL/title string
  nsCOMPtr<nsISupportsString> strObject ( do_QueryInterface(aGenericData));
  if (!strObject)
    return NS_ERROR_FAILURE;
  nsAutoString strData;
  strObject->GetData(strData);

    // split string into URL and Title - 
    // if there's a title but no URL, there's no reason to continue
  PRInt32 lineIndex = strData.FindChar ('\n');
  if (lineIndex == 0)
    return NS_ERROR_FAILURE;

    // get the URL portion of the text
  nsAutoString strUrl;
  if (lineIndex == -1)
    strUrl = strData;
  else
    strData.Left(strUrl, lineIndex);

    // save the URL for later use
  nsCOMPtr<nsIURI> saveURI;
  NS_NewURI(getter_AddRefs(saveURI), strUrl);
  if (!saveURI)
    return NS_ERROR_FAILURE;

    // if there's a bona-fide title & it isn't just a copy of the URL,
    // limit it to a reasonable length, perform NLS conversion, then return

  if (++lineIndex && lineIndex != (int)strData.Length() &&
      !strUrl.Equals(Substring(strData, lineIndex, strData.Length()))) {
    PRUint32 strLth = NS_MIN((int)strData.Length()-lineIndex, MAXTITLELTH);
    nsAutoString strTitle;
    strData.Mid(strTitle, lineIndex, strLth);
    if (!UnicodeToCodepage(strTitle, aTargetName))
      return NS_ERROR_FAILURE;

    mSourceData = do_QueryInterface(saveURI);
    mMimeType = kURLMime;
    return NS_OK;
  }

    // if the URI can be handled as a URL, construct a title from
    // the hostname & filename;  if not, use the first MAXTITLELTH
    // characters that appear after the scheme name

  nsCAutoString strTitle;

  nsCOMPtr<nsIURL> urlObj( do_QueryInterface(saveURI));
  if (urlObj) {
    nsCAutoString strFile;

    urlObj->GetHost(strTitle);
    urlObj->GetFileName(strFile);
    if (!strFile.IsEmpty()) {
      strTitle.AppendLiteral("/");
      strTitle.Append(strFile);
    }
    else {
      urlObj->GetDirectory(strFile);
      if (strFile.Length() > 1) {
        nsCAutoString::const_iterator start, end, curr;
        strFile.BeginReading(start);
        strFile.EndReading(end);
        strFile.EndReading(curr);
        for (curr.advance(-2); curr != start; --curr)
          if (*curr == '/')
            break;
        strTitle.Append(Substring(curr, end));
      }
    }
  }
  else {
    saveURI->GetSpec(strTitle);
    PRInt32 index = strTitle.FindChar (':');
    if (index != -1) {
      if ((strTitle.get())[++index] == '/')
        if ((strTitle.get())[++index] == '/')
          ++index;
      strTitle.Cut(0, index);
    }
    if (strTitle.Length() > MAXTITLELTH)
      strTitle.Truncate(MAXTITLELTH);
  }

  *aTargetName = ToNewCString(strTitle);

  mSourceData = do_QueryInterface(saveURI);
  mMimeType = kURLMime;
  return NS_OK;
}

Here is the call graph for this function:

NS_IMETHOD nsDragService::InvokeDragSession ( nsIDOMNode aDOMNode,
nsISupportsArray anArrayTransferables,
nsIScriptableRegion aRegion,
PRUint32  aActionType 
)
NS_IMETHODIMP nsDragService::InvokeDragSession ( nsIDOMNode aDOMNode,
nsISupportsArray anArrayTransferables,
nsIScriptableRegion aRegion,
PRUint32  aActionType 
)

Definition at line 153 of file nsDragService.cpp.

{
    PR_LOG(sDragLm, PR_LOG_DEBUG, ("nsDragService::InvokeDragSession"));
    nsresult rv = nsBaseDragService::InvokeDragSession(aDOMNode,
                                                       aArrayTransferables,
                                                       aRegion, aActionType);
    NS_ENSURE_SUCCESS(rv, rv);

    ResetDragInfo();       
    // make sure that we have an array of transferables to use
    if (nsnull == aArrayTransferables)
        return NS_ERROR_INVALID_ARG;

    // set our reference to the transferables.  this will also addref
    // the transferables since we're going to hang onto this beyond the
    // length of this call
    mSourceDataItems = aArrayTransferables;

    // Get a box or a bitmap to drag
    bool haveRect = false;
    BRect dragRect;
       
    if (nsnull != aRegion)
    {
        PRInt32 aX, aY, aWidth, aHeight;
        // TODO. Region may represent multiple rects - when dragging multiple items.
        aRegion->GetBoundingBox(&aX, &aY, &aWidth, &aHeight);
        dragRect.Set( aX, aY, aX + aWidth, aY + aHeight);
        haveRect = true;
        // does this need to be offset?
    } 
    
    // Get the frame for this content node (note: frames are not refcounted)
    nsIFrame *aFrame = GetPrimaryFrameFor(aDOMNode);
    if (nsnull == aFrame)
        return PR_FALSE;
    
    // Now that we have the frame, we have to convert its coordinates into global screen
    // coordinates.
    nsRect aRect = aFrame->GetRect();

    // Find offset from our view
    nsIView *containingView = nsnull;
    nsPoint viewOffset(0,0);
    aFrame->GetOffsetFromView(viewOffset, &containingView);
    NS_ASSERTION(containingView, "No containing view!");
    if (nsnull == containingView)
        return PR_FALSE;

    // get the widget associated with the containing view. 
    nsPoint aWidgetOffset;
    nsCOMPtr<nsIWidget> aWidget = containingView->GetNearestWidget(&aWidgetOffset);
    if (nsnull == aWidget)
        return PR_FALSE;

    BView *view = (BView *) aWidget->GetNativeData(NS_NATIVE_WIDGET);
    // Don't have the rect yet, try to get it from the dom node
    if (nsnull==haveRect)
    {
        float t2p =  aFrame->GetPresContext()->TwipsToPixels(); 
        // GetOffsetFromWidget() actually returns the _parent's_ offset from its widget, so we
        // still have to add in the offset to |containingView|'s parent ourselves.
        nsPoint aViewPos = containingView->GetPosition();
    
        // Shift our offset rect by offset into our view, the view's offset to its parent, and
        // the parent's offset to the closest widget. Then convert that to global coordinates. 
        // Recall that WidgetToScreen() will give us the global coordinates of the rectangle we 
        // give it, but it expects  everything to be in pixels.
        nsRect screenOffset;
        screenOffset.MoveBy ( NSTwipsToIntPixels(aWidgetOffset.x + aViewPos.x + viewOffset.x, t2p),
                            NSTwipsToIntPixels(aWidgetOffset.y + aViewPos.y + viewOffset.y, t2p));
        aWidget->WidgetToScreen ( screenOffset, screenOffset );

        dragRect.Set(screenOffset.x, screenOffset.y, 
                           screenOffset.x + NSTwipsToIntPixels(aRect.width, t2p),
                           screenOffset.y + NSTwipsToIntPixels(aRect.height, t2p));
        haveRect = true;
    }

    mDragAction = aActionType;
    mDragMessage = CreateDragMessage();

    if (!view || !mDragMessage)
        return PR_FALSE;
        
    // Set the original click location, how to get this or is it needed ?
    // sourceMessage->AddPoint("click_location", mPoint);
    
    if (!view->LockLooper())
        return PR_FALSE;
        
    // Well, let's just use the view frame, maybe?
    if (!haveRect) 
    {
        dragRect = view->Frame();
        // do we need to offset?
    }
        
    PR_LOG(sDragLm, PR_LOG_DEBUG, ("invoking mDragView->DragMessage"));
    bool noBitmap = true;

//This is the code for image-dragging, currently disabled. See comments in beginning of file.
# ifdef 0
    do
    {
        PRUint32 dataSize;
        PRUint32 noItems;
        mSourceDataItems->Count(&noItems);
        if (noItems!=1) 
        {
            PR_LOG(sDragLm, PR_LOG_DEBUG, ("Transferables are not ==1, no drag bitmap!"));
            break;
        }
        
        nsCOMPtr<nsISupports> genericItem;
        aArrayTransferables->GetElementAt(0, getter_AddRefs(genericItem));
        nsCOMPtr<nsITransferable> aTransferable (do_QueryInterface(genericItem));
        
        nsCOMPtr<nsISupports> genericDataWrapper;
        nsresult rv = aTransferable->GetTransferData(kNativeImageMime, getter_AddRefs(genericDataWrapper), &dataSize);
        if (NS_FAILED(rv))
        {
            PR_LOG(sDragLm, PR_LOG_DEBUG, ("Could not get nativeimage, no drag bitmap!"));
            break;
        }

        nsCOMPtr<nsISupportsInterfacePointer> ptrPrimitive (do_QueryInterface(genericDataWrapper));
        if (ptrPrimitive == NULL) 
        {
            PR_LOG(sDragLm, PR_LOG_DEBUG, ("Could not get ptrPrimitive, no drag bitmap!"));
            break;
        }

        nsCOMPtr<nsISupports> genericData;
        ptrPrimitive->GetData(getter_AddRefs(genericData));
        if (genericData == NULL) 
        {
            PR_LOG(sDragLm, PR_LOG_DEBUG, ("Could not get data, no drag bitmap!"));
            break;
        }

        //dependent on bug 294234 and how it's implemented. This code was for attachment 183634.
        nsCOMPtr<nsIImageBeOS> image (do_QueryInterface(genericData));
        if (image == NULL)
        {
            PR_LOG(sDragLm, PR_LOG_DEBUG, ("Could not get nsImage, no drag bitmap!"));
            break;
        }

        BBitmap *aBitmap;
        image->GetBitmap(&aBitmap);
        if (aBitmap==NULL || !aBitmap->IsValid()) {
            PR_LOG(sDragLm, PR_LOG_DEBUG, ("Could not get BBitmap, no drag bitmap %s!", aBitmap==NULL?"(null)":"(not valid)" ));
            break;        
        }

        view->DragMessage(mDragMessage, aBitmap, B_OP_OVER, BPoint(-4,-4), view); 
        noBitmap = false;
    } while(false);
# endif    
    
    if (noBitmap) 
        view->DragMessage(mDragMessage, dragRect, view);
    
    StartDragSession();
    view->UnlockLooper();
    return NS_OK;

Here is the call graph for this function:

void nsIDragService::invokeDragSession ( in nsIDOMNode  aDOMNode,
in nsISupportsArray  aTransferables,
in nsIScriptableRegion  aRegion,
in unsigned long  aActionType 
) [inherited]

Starts a modal drag session with an array of transaferables.

Parameters:
aTransferables- an array of transferables to be dragged
aRegion- a region containing rectangles for cursor feedback, in window coordinates.
aActionType- specified which of copy/move/link are allowed
NS_IMETHOD nsDragService::InvokeDragSession ( nsIDOMNode aDOMNode,
nsISupportsArray anArrayTransferables,
nsIScriptableRegion aRegion,
PRUint32  aActionType 
)
NS_IMETHOD nsDragService::InvokeDragSession ( nsIDOMNode aDOMNode,
nsISupportsArray anArrayTransferables,
nsIScriptableRegion aRegion,
PRUint32  aActionType 
)
NS_DECL_ISUPPORTS_INHERITED NS_DECL_NSIOBSERVER NS_IMETHOD nsDragService::InvokeDragSession ( nsIDOMNode aDOMNode,
nsISupportsArray anArrayTransferables,
nsIScriptableRegion aRegion,
PRUint32  aActionType 
)
NS_DECL_ISUPPORTS_INHERITED NS_DECL_NSIOBSERVER NS_IMETHOD nsDragService::InvokeDragSession ( nsIDOMNode aDOMNode,
nsISupportsArray anArrayTransferables,
nsIScriptableRegion aRegion,
PRUint32  aActionType 
)
PRBool nsDragService::IsCollectionObject ( IDataObject *  inDataObj) [protected]

Definition at line 418 of file nsDragService.cpp.

{
  PRBool isCollection = PR_FALSE;

  // setup the format object to ask for the MULTI_MIME format. We only
  // need to do this once
  static UINT sFormat = 0;
  static FORMATETC sFE;
  if (!sFormat) {
    sFormat = nsClipboard::GetFormat(MULTI_MIME);
    SET_FORMATETC(sFE, sFormat, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL);
  }

  // ask the object if it supports it. If yes, we have a collection
  // object
  if (inDataObj->QueryGetData(&sFE) == S_OK)
    isCollection = PR_TRUE;

  return isCollection;

} // IsCollectionObject
NS_IMETHOD nsDragService::IsDataFlavorSupported ( const char *  aDataFlavor,
PRBool _retval 
)
NS_IMETHOD nsDragService::IsDataFlavorSupported ( const char *  aDataFlavor,
PRBool _retval 
)
NS_IMETHOD nsDragService::IsDataFlavorSupported ( const char *  aDataFlavor,
PRBool _retval 
)
NS_IMETHOD nsDragService::IsDataFlavorSupported ( const char *  aDataFlavor,
PRBool _retval 
)
NS_IMETHOD nsDragService::IsDataFlavorSupported ( const char *  aDataFlavor,
PRBool _retval 
)
NS_IMETHODIMP nsDragService::IsDataFlavorSupported ( const char *  aDataFlavor,
PRBool _retval 
)

Definition at line 501 of file nsDragService.cpp.

{
    PR_LOG(sDragLm, PR_LOG_DEBUG, ("nsDragService::IsDataFlavorSupported %s", aDataFlavor));
    if (!_retval)
        return NS_ERROR_INVALID_ARG;

    // set this to no by default
    *_retval = PR_FALSE;

    // check to make sure that we have a drag object set, here
    if (nsnull == mDragMessage) {
        PR_LOG(sDragLm, PR_LOG_DEBUG, ("*** warning: IsDataFlavorSupported called without a valid drag context!"));
        return NS_OK;
    }

    if (IsInternalDrag(mDragMessage))
    {
        PRUint32 numDragItems = 0;
        // if we don't have mDataItems we didn't start this drag so it's
        // an external client trying to fool us.
        if (nsnull == mSourceDataItems)
            return NS_OK;
        mSourceDataItems->Count(&numDragItems);
        if (0 == numDragItems)
            PR_LOG(sDragLm, PR_LOG_DEBUG, ("*** warning: Number of dragged items is zero!"));

        // For all dragged items compare their flavors to the one wanted. If there is a match DataFlavor is supported.
        nsCOMPtr<nsISupports> genericItem;
        nsCOMPtr <nsISupportsArray> flavorList;
        PRUint32 numFlavors;
        for (PRUint32 itemIndex = 0; itemIndex < numDragItems; ++itemIndex)
        {
            mSourceDataItems->GetElementAt(itemIndex, getter_AddRefs(genericItem));
            nsCOMPtr<nsITransferable> currItem (do_QueryInterface(genericItem));
            if (nsnull == currItem)
                continue;
            currItem->FlavorsTransferableCanExport(getter_AddRefs(flavorList));
            if (nsnull == flavorList)
                continue;
            flavorList->Count( &numFlavors );
            
            nsCOMPtr<nsISupports> genericWrapper;
            nsXPIDLCString flavorStr;
            for ( PRUint32 flavorIndex = 0; flavorIndex < numFlavors ; ++flavorIndex ) {
                flavorList->GetElementAt (flavorIndex, getter_AddRefs(genericWrapper));
                nsCOMPtr<nsISupportsCString> currentFlavor = do_QueryInterface(genericWrapper);
                if (nsnull == currentFlavor)
                    continue;
                currentFlavor->ToString ( getter_Copies(flavorStr) );
                PR_LOG(sDragLm, PR_LOG_DEBUG, ("nsDragService::IsDataFlavorSupported checking %s against %s", (const char *)flavorStr, aDataFlavor));
                if (0 != strcmp(flavorStr, aDataFlavor))
                    continue;
                PR_LOG(sDragLm, PR_LOG_DEBUG, ("nsDragService::IsDataFlavorSupported Got the flavor!"));
                *_retval = PR_TRUE;
                return NS_OK;
            }
        }
    }
    else 
    {
        PR_LOG(sDragLm, PR_LOG_DEBUG, ("*** warning: Native drag not implemented."));
        // TODO: implement native checking
    }
    PR_LOG(sDragLm, PR_LOG_DEBUG, ("nsDragService::IsDataFlavorSupported FALSE"));
    return NS_OK;

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHOD nsDragService::IsDataFlavorSupported ( const char *  aDataFlavor,
PRBool _retval 
)
NS_IMETHOD nsDragService::IsDataFlavorSupported ( const char *  aDataFlavor,
PRBool _retval 
)
NS_IMETHOD nsDragService::IsDataFlavorSupported ( const char *  aDataFlavor,
PRBool _retval 
)

Check to set if ant of the native data on the clipboard matches this data flavor.

Returns:
NS_OK if if the data flavor is supported and, NS_ERROR_FAILURE is it is not

Implements nsIDragSessionXlib.

Definition at line 249 of file nsDragService.cpp.

                                                      {
  *result = mDragging;
  return NS_OK;
}

Definition at line 750 of file nsDragService.cpp.

{
  PRBool retval = PR_FALSE;

  if (!mTargetDragContext)
    return retval;

  // gMimeListType drags only work for drags within a single process.
  // The gtk_drag_get_source_widget() function will return NULL if the
  // source of the drag is another app, so we use it to check if a
  // gMimeListType drop will work or not.
  if (gtk_drag_get_source_widget(mTargetDragContext) == NULL)
    return retval;

  GList *tmp;

  // walk the list of context targets and see if one of them is a list
  // of items.
  for (tmp = mTargetDragContext->targets; tmp; tmp = tmp->next) {
    GdkAtom atom = GPOINTER_TO_INT(tmp->data);
    gchar *name = NULL;
    name = gdk_atom_name(atom);
    if (strcmp(name, gMimeListType) == 0)
      retval = PR_TRUE;
    g_free(name);
    if (retval)
      break;
  }
  return retval;
}
char * nsDragService::LookupMimeMappingsForItem ( DragReference  inDragRef,
ItemReference  itemRef 
) [private]

Definition at line 1050 of file nsDragService.cpp.

{
  char* mapperData = nsnull;
  PRUint32 mapperSize = 0;
  ExtractDataFromOS(inDragRef, inItemRef, nsMimeMapperMac::MappingFlavor(),  (void**)&mapperData, &mapperSize);

  return mapperData;
  
#if 0 
  OSErr err = ::GetFlavorDataSize ( inDragRef, itemRef, nsMimeMapperMac::MappingFlavor(), &mapperSize );
  if ( !err && mapperSize > 0 ) {
    mapperData = NS_REINTERPRET_CAST(char*, nsMemory::Alloc(mapperSize + 1));
    if ( !mapperData )
      return nsnull;
                 
    err = ::GetFlavorData ( inDragRef, itemRef, nsMimeMapperMac::MappingFlavor(), mapperData, &mapperSize, 0 );
    if ( err ) {
      #ifdef NS_DEBUG
        printf("nsDragService: Error getting data out of drag manager for mime mapper, #%ld\n", err);
      #endif
      return nsnull;
    }
    else
      mapperData[mapperSize] = '\0';    // null terminate the data
  }

  return mapperData; 
#endif
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsDragService::NativeDataToTransferable ( PCSZ  pszText,
PCSZ  pszTitle,
PRBool  isUrl 
) [protected, virtual]

Implements nsIDragSessionOS2.

Definition at line 1275 of file nsDragService.cpp.

{
  nsresult rv = NS_ERROR_FAILURE;
    // the transferable should have been created on DragEnter
 if (!mSourceDataItems)
    return rv;

  nsCOMPtr<nsISupports> genericItem;
  mSourceDataItems->GetElementAt(0, getter_AddRefs(genericItem));
  nsCOMPtr<nsITransferable> trans (do_QueryInterface(genericItem));
  if (!trans)
    return rv;

    // remove invalid flavors
  if (!isUrl) {
    trans->RemoveDataFlavor(kURLMime);
    trans->RemoveDataFlavor(kHTMLMime);
  }

    // if there's no text, exit - but first see if we have the title of
    // a Url that needs to be rendered;  if so, stash it for later use
  if (!pszText || !*pszText) {
    if (isUrl && pszTitle && *pszTitle) {
      nsXPIDLString outTitle;
      if (CodepageToUnicode(nsDependentCString(pszTitle),
                                               getter_Copies(outTitle))) {
        nsCOMPtr<nsISupportsString> urlPrimitive(
                        do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID));
        if (urlPrimitive ) {
          urlPrimitive->SetData(outTitle);
          trans->SetTransferData(kURLDescriptionMime, urlPrimitive,
                                 2*outTitle.Length());
        }
      }
    }
    return NS_OK;
  }

  nsXPIDLString outText;
  if (!CodepageToUnicode(nsDependentCString(pszText), getter_Copies(outText)))
    return rv;

  if (isUrl) {

      // if no title was supplied, see if it was stored in the transferable
    nsXPIDLString outTitle;
    if (pszTitle && *pszTitle) {
      if (!CodepageToUnicode(nsDependentCString(pszTitle),
                             getter_Copies(outTitle)))
        return rv;
    }
    else {
      PRUint32 len;
      nsCOMPtr<nsISupports> genericData;
      if (NS_SUCCEEDED(trans->GetTransferData(kURLDescriptionMime,
                                   getter_AddRefs(genericData), &len))) {
        nsCOMPtr<nsISupportsString> strObject(do_QueryInterface(genericData));
        if (strObject)
          strObject->GetData(outTitle);
      }
    }

      // construct the Url flavor
    nsCOMPtr<nsISupportsString> urlPrimitive(
                            do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID));
    if (urlPrimitive ) {
      if (outTitle.IsEmpty()) {
        urlPrimitive->SetData(outText);
        trans->SetTransferData(kURLMime, urlPrimitive, 2*outText.Length());
      }
      else {
        nsString urlStr( outText + NS_LITERAL_STRING("\n") + outTitle);
        urlPrimitive->SetData(urlStr);
        trans->SetTransferData(kURLMime, urlPrimitive, 2*urlStr.Length());
      }
      rv = NS_OK;
    }

      // construct the HTML flavor - for supported graphics,
      // use an IMG tag, for all others create a link
    nsCOMPtr<nsISupportsString> htmlPrimitive(
                            do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID));
    if (htmlPrimitive ) {
      nsString htmlStr;
      nsCOMPtr<nsIURI> uri;

      rv = NS_ERROR_FAILURE;
      if (NS_SUCCEEDED(NS_NewURI(getter_AddRefs(uri), pszText))) {
        nsCOMPtr<nsIURL> url (do_QueryInterface(uri));
        if (url) {
          nsCAutoString extension;
          url->GetFileExtension(extension);
          if (!extension.IsEmpty()) {
            if (extension.LowerCaseEqualsLiteral("gif") ||
                extension.LowerCaseEqualsLiteral("jpg") ||
                extension.LowerCaseEqualsLiteral("png") ||
                extension.LowerCaseEqualsLiteral("jpeg"))
              rv = NS_OK;
          }
        }
      }

      if (NS_SUCCEEDED(rv))
        htmlStr.Assign(NS_LITERAL_STRING("<img src=\"") +
                       outText +
                       NS_LITERAL_STRING("\" alt=\"") +
                       outTitle +
                       NS_LITERAL_STRING("\"/>") );
      else
        htmlStr.Assign(NS_LITERAL_STRING("<a href=\"") +
                       outText +
                       NS_LITERAL_STRING("\">") +
                       (outTitle.IsEmpty() ? outText : outTitle) +
                       NS_LITERAL_STRING("</a>") );

      htmlPrimitive->SetData(htmlStr);
      trans->SetTransferData(kHTMLMime, htmlPrimitive, 2*htmlStr.Length());
      rv = NS_OK;
    }
  }

    // add the Text flavor
  nsCOMPtr<nsISupportsString> textPrimitive(
                            do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID));
  if (textPrimitive ) {
    textPrimitive->SetData(nsDependentString(outText));
    trans->SetTransferData(kUnicodeMime, textPrimitive, 2*outText.Length());
    rv = NS_OK;
  }

    // return OK if we put anything in the transferable
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsDragService::NativeDragEnter ( PDRAGINFO  pdinfo) [protected, virtual]

Implements nsIDragSessionOS2.

Definition at line 826 of file nsDragService.cpp.

{
  nsresult  rv = NS_ERROR_FAILURE;
  PRBool    isFQFile = FALSE;
  PRBool    isAtom = FALSE;
  PDRAGITEM pditem = 0;

  if (pdinfo->cditem != 1)
    return rv;

  pditem = DrgQueryDragitemPtr(pdinfo, 0);

  if (pditem) {
    if (DrgVerifyRMF(pditem, "DRM_ATOM", 0)) {
      isAtom = TRUE;
      rv = NS_OK;
    }
    else
    if (DrgVerifyRMF(pditem, "DRM_DTSHARE", 0))
      rv = NS_OK;
    else
    if (DrgVerifyRMF(pditem, "DRM_OS2FILE", 0)) {
      rv = NS_OK;
      if (pditem->hstrContainerName && pditem->hstrSourceName)
        isFQFile = TRUE;
    }
  }

  if (NS_SUCCEEDED(rv)) {
    rv = NS_ERROR_FAILURE;
    nsCOMPtr<nsITransferable> trans(
            do_CreateInstance("@mozilla.org/widget/transferable;1", &rv));
    if (trans) {

      PRBool isUrl = DrgVerifyType(pditem, "UniformResourceLocator");
      PRBool isAlt = (WinGetKeyState(HWND_DESKTOP, VK_ALT) & 0x8000);

        // if this is a fully-qualified file or the item claims to be
        // a Url, identify it as a Url & also offer it as html
      if ((isFQFile && !isAlt) || isUrl) {
        trans->AddDataFlavor(kURLMime);
        trans->AddDataFlavor(kHTMLMime);
      }

        // everything is always "text"
      trans->AddDataFlavor(kUnicodeMime);

        // if we can create the array, initialize the session
      nsCOMPtr<nsISupportsArray> transArray(
                    do_CreateInstance("@mozilla.org/supports-array;1", &rv));
      if (transArray) {
        transArray->InsertElementAt(trans, 0);
        mSourceDataItems = transArray;

        // add the dragged data to the transferable if we have easy access
        // to it (i.e. no need to read a file or request rendering);  for
        // URLs, we'll skip creating a title until the drop occurs
        nsXPIDLCString someText;
        if (isAtom) {
          if (NS_SUCCEEDED(GetAtom(pditem->ulItemID, getter_Copies(someText))))
            NativeDataToTransferable( someText.get(), 0, isUrl);
        }
        else
        if (isFQFile && !isAlt &&
            NS_SUCCEEDED(GetFileName(pditem, getter_Copies(someText)))) {
          nsCOMPtr<nsILocalFile> file;
          if (NS_SUCCEEDED(NS_NewNativeLocalFile(someText, PR_TRUE,
                                                 getter_AddRefs(file)))) {
            nsCAutoString textStr;
            NS_GetURLSpecFromFile(file, textStr);
            if (!textStr.IsEmpty()) {
              someText.Assign(ToNewCString(textStr));
              NativeDataToTransferable( someText.get(), 0, TRUE);
            }
          }
        }

        mSourceNode = 0;
        mSourceDocument = 0;
        mDoingDrag = TRUE;
        rv = NS_OK;
      }
    }
  }

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsDragService::NativeDrop ( PDRAGINFO  pdinfo,
HWND  hwnd,
PRBool rendering 
) [protected, virtual]

Implements nsIDragSessionOS2.

Definition at line 1102 of file nsDragService.cpp.

{
  *rendering = PR_FALSE;

  nsresult rv = NS_ERROR_FAILURE;
  PDRAGITEM pditem = DrgQueryDragitemPtr(pdinfo, 0);
  if (!pditem)
    return rv;

  nsXPIDLCString dropText;
  PRBool isUrl = DrgVerifyType(pditem, "UniformResourceLocator");

    // identify format; the order of evaluation here is important

    // DRM_ATOM - DragText stores up to 255 chars in a Drg API atom
    // DRM_DTSHARE - DragText renders up to 1mb to named shared mem
  if (DrgVerifyRMF(pditem, "DRM_ATOM", 0))
    rv = GetAtom(pditem->ulItemID, getter_Copies(dropText));
  else
  if (DrgVerifyRMF(pditem, "DRM_DTSHARE", 0)) {
    rv = RenderToDTShare( pditem, hwnd);
    if (NS_SUCCEEDED(rv))
      *rendering = PR_TRUE;
  }

    // DRM_OS2FILE - get the file's path or contents if it exists;
    // request rendering if it doesn't
  else
  if (DrgVerifyRMF(pditem, "DRM_OS2FILE", 0)) {
    PRBool isAlt = (WinGetKeyState(HWND_DESKTOP, VK_ALT) & 0x8000);

      // the file has to be rendered - currently, we only present
      // its content, not its name, to Moz to avoid conflicts
    if (!pditem->hstrContainerName || !pditem->hstrSourceName) {
      rv = RenderToOS2File( pditem, hwnd);
      if (NS_SUCCEEDED(rv))
        *rendering = PR_TRUE;
    }
      // for Url objects and 'Alt+Drop', get the file's contents;
      // otherwise, convert it's path to a Url
    else {
      nsXPIDLCString fileName;
      if (NS_SUCCEEDED(GetFileName(pditem, getter_Copies(fileName)))) {
        if (isUrl || isAlt)
          rv = GetFileContents(fileName.get(), getter_Copies(dropText));
        else {
          isUrl = PR_TRUE;
          nsCOMPtr<nsILocalFile> file;
          if (NS_SUCCEEDED(NS_NewNativeLocalFile(fileName,
                                         PR_TRUE, getter_AddRefs(file)))) {
            nsCAutoString textStr;
            NS_GetURLSpecFromFile(file, textStr);
            if (!textStr.IsEmpty()) {
              dropText.Assign(ToNewCString(textStr));
              rv = NS_OK;
            }
          }
        } // filename as Url
      } // got filename
    } // existing files
  } // DRM_OS2FILE

    // if OK, put what data there is in the transferable;  this could be
    // everything needed or just the title of a Url that needs rendering
  if (NS_SUCCEEDED(rv)) {

      // for Urls, get the title & remove any linefeeds
    nsXPIDLCString titleText;
    if (isUrl &&
        pditem->hstrTargetName &&
        NS_SUCCEEDED(GetAtom(pditem->hstrTargetName, getter_Copies(titleText))))
      for (char* ptr=strchr(titleText.BeginWriting(),'\n'); ptr; ptr=strchr(ptr, '\n'))
        *ptr = ' ';

    rv = NativeDataToTransferable( dropText.get(), titleText.get(), isUrl);
  }

    // except for renderings, tell the source we're done with the data
  if (!*rendering)
    DrgSendTransferMsg( pditem->hwndItem, DM_ENDCONVERSATION,
                        (MPARAM)pditem->ulItemID,
                        (MPARAM)DMFL_TARGETSUCCESSFUL);

  return (rv);
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsDragService::NativeRenderComplete ( PDRAGTRANSFER  pdxfer,
USHORT  usResult 
) [protected, virtual]

Implements nsIDragSessionOS2.

Definition at line 1239 of file nsDragService.cpp.

{
  nsresult rv = NS_ERROR_FAILURE;
  nsXPIDLCString rmf;

    // identify the rendering mechanism, then get the data
  if (NS_SUCCEEDED(GetAtom(pdxfer->hstrSelectedRMF, getter_Copies(rmf)))) {
    nsXPIDLCString dropText;
    if (!strcmp(rmf.get(), DTSHARE_RMF))
      rv = RenderToDTShareComplete(pdxfer, usResult, getter_Copies(dropText));
    else
    if (!strcmp(rmf.get(), OS2FILE_TXTRMF) ||
        !strcmp(rmf.get(), OS2FILE_UNKRMF))
      rv = RenderToOS2FileComplete(pdxfer, usResult, PR_TRUE,
                                   getter_Copies(dropText));

    if (NS_SUCCEEDED(rv)) {
      PRBool isUrl = PR_FALSE;
      IsDataFlavorSupported(kURLMime, &isUrl);
      rv = NativeDataToTransferable( dropText.get(), 0, isUrl);
    }
  }

  DrgSendTransferMsg(pdxfer->hwndClient, DM_ENDCONVERSATION,
                     (MPARAM)pdxfer->ulTargetInfo,
                     (MPARAM)DMFL_TARGETSUCCESSFUL);

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIObserver::observe ( in nsISupports  aSubject,
in string  aTopic,
in wstring  aData 
) [inherited]

Observe will be called when there is a notification for the topic |aTopic|.

This assumes that the object implementing this interface has been registered with an observer service such as the nsIObserverService.

If you expect multiple topics/subjects, the impl is responsible for filtering.

You should not modify, add, remove, or enumerate notifications in the implemention of observe.

Parameters:
aSubject: Notification specific interface pointer.
aTopic: The notification topic or subject.
aData: Notification specific wide string. subject event.
QDragObject * nsDragService::RegisterDragFlavors ( nsITransferable transferable) [protected]

Definition at line 144 of file nsDragService.cpp.

{
    nsMimeStore *pMimeStore = new nsMimeStore();
    nsCOMPtr<nsISupportsArray> flavorList;

    if (NS_SUCCEEDED(transferable->FlavorsTransferableCanExport(getter_AddRefs(flavorList)))) {
        PRUint32 numFlavors;

        flavorList->Count(&numFlavors);

        for (PRUint32 flavorIndex = 0; flavorIndex < numFlavors; ++flavorIndex) {
            nsCOMPtr<nsISupports> genericWrapper;

            flavorList->GetElementAt(flavorIndex,getter_AddRefs(genericWrapper));

            nsCOMPtr<nsISupportsCString> currentFlavor(do_QueryInterface(genericWrapper));

            if (currentFlavor) {
                nsXPIDLCString flavorStr;

                currentFlavor->ToString(getter_Copies(flavorStr));

                PRUint32   len;
                nsCOMPtr<nsISupports> clip;

                transferable->GetTransferData(flavorStr,getter_AddRefs(clip),&len);

                nsCOMPtr<nsISupportsString> wideString;
                wideString = do_QueryInterface(clip);
                if (!wideString)
                    continue;

                nsAutoString ucs2string;
                wideString->GetData(ucs2string);
                QString str = QString::fromUcs2(ucs2string.get());

                pMimeStore->AddFlavorData(flavorStr,str.utf8());
            }
        } // foreach flavor in item
    } // if valid flavor list
#ifdef NS_DEBUG
    else
        printf(" DnD ERROR: cannot export any flavor\n");
#endif
    return new nsDragObject(pMimeStore,mHiddenWidget);
} // RegisterDragItemsAndFlavors

Here is the call graph for this function:

Definition at line 405 of file nsDragService.cpp.

{
  const FlavorFlags flags = 0;
  
  Rect      dragRgnBounds = {0, 0, 0, 0};
  if (inDragRgn)
    GetRegionBounds(inDragRgn, &dragRgnBounds);

  PRUint32 numDragItems = 0;
  inArray->Count ( &numDragItems ) ;
  for ( PRUint32 itemIndex = 0; itemIndex < numDragItems; ++itemIndex ) {
    nsMimeMapperMac theMapper;
  
    nsCOMPtr<nsISupports> genericItem;
    inArray->GetElementAt ( itemIndex, getter_AddRefs(genericItem) );
    nsCOMPtr<nsITransferable> currItem ( do_QueryInterface(genericItem) );
    if ( currItem ) {   
      nsCOMPtr<nsISupportsArray> flavorList;
      if ( NS_SUCCEEDED(currItem->FlavorsTransferableCanExport(getter_AddRefs(flavorList))) ) {
        PRUint32 numFlavors;
        flavorList->Count ( &numFlavors );
        for ( PRUint32 flavorIndex = 0; flavorIndex < numFlavors; ++flavorIndex ) {
        
          nsCOMPtr<nsISupports> genericWrapper;
          flavorList->GetElementAt ( flavorIndex, getter_AddRefs(genericWrapper) );
          nsCOMPtr<nsISupportsCString> currentFlavor ( do_QueryInterface(genericWrapper) );
             if ( currentFlavor ) {
               nsCAutoString flavorStr;
               currentFlavor->GetData(flavorStr);
               FlavorType macOSFlavor = theMapper.MapMimeTypeToMacOSType(flavorStr.get());
              
            if (macOSFlavor == kDragFlavorTypePromiseHFS) {
              // we got kFilePromiseMime
              // kDragFlavorTypePromiseHFS is special. See http://developer.apple.com/technotes/tn/tn1085.html
              PromiseHFSFlavor promiseData;
              promiseData.fileType           = 0;     // let the file extension prevail!
              promiseData.fileCreator        = 0;
              promiseData.fdFlags            = 0;
              promiseData.promisedFlavor     = kDragPromisedFlavor;

              ::AddDragItemFlavor(mDragRef, itemIndex, kDragFlavorTypePromiseHFS, &promiseData, sizeof(promiseData), flavorNotSaved);
              ::AddDragItemFlavor(mDragRef, itemIndex, kDragPromisedFlavor, NULL, 0, flavorNotSaved);
            }
            else
              ::AddDragItemFlavor(mDragRef, itemIndex, macOSFlavor, NULL, 0, flags);
               
               // If we advertise text/unicode, then make sure we add 'TEXT' to the list
               // of flavors supported since we will do the conversion ourselves in GetDataForFlavor()
               if ( strcmp(flavorStr.get(), kUnicodeMime) == 0 ) {
                 theMapper.MapMimeTypeToMacOSType(kTextMime);
                 ::AddDragItemFlavor ( mDragRef, itemIndex, 'TEXT', NULL, 0, flags );              
                 ::AddDragItemFlavor ( mDragRef, itemIndex, 'styl', NULL, 0, flags );              
               }
             }
          
        } // foreach flavor in item              
      } // if valid flavor list
    } // if item is a transferable
    
    // put the mime mapping data for this item in a special flavor. Unlike the other data,
    // we have to put the data in now (rather than defer it) or the mappings will go out 
    // of scope by the time they are asked for. Remember that the |mappingLen|
    // includes the null, and we need to maintain that for when we parse it.
    short mappingLen;
    char* mapping = theMapper.ExportMapping(&mappingLen);
    if ( mapping && mappingLen ) {
      ::AddDragItemFlavor ( mDragRef, itemIndex, nsMimeMapperMac::MappingFlavor(), 
                               mapping, mappingLen, flags );
           nsMemory::Free ( mapping );
    
      ::SetDragItemBounds(mDragRef, itemIndex, &dragRgnBounds);
         }
    
  } // foreach drag item 

} // RegisterDragItemsAndFlavors

Here is the call graph for this function:

NS_IMETHODIMP nsDragService::RenderCompleteMsg ( PDRAGTRANSFER  pdxfer,
USHORT  usResult,
PRUint32 dragFlags 
) [virtual]

Implements nsIDragSessionOS2.

Definition at line 1197 of file nsDragService.cpp.

{
  nsresult rv = NS_ERROR_FAILURE;
  if (!mDoingDrag || !pdxfer)
    return rv;

    // this msg should never come from Moz - if it does, fail
  if (!mSourceNode)
    rv = NativeRenderComplete(pdxfer, usResult);

    // DrgQueryDraginfoPtrFromDragitem() doesn't work - this does
  PDRAGINFO pdinfo = (PDRAGINFO)MAKEULONG(0x2c, HIUSHORT(pdxfer->pditem));

  DrgDeleteStrHandle(pdxfer->hstrSelectedRMF);
  DrgDeleteStrHandle(pdxfer->hstrRenderToName);
  DrgFreeDragtransfer(pdxfer);

    // if the source is Moz, don't touch pdinfo - it's been freed already
  if (pdinfo && !mSourceNode) {
    DrgDeleteDraginfoStrHandles(pdinfo);
    DrgFreeDraginfo(pdinfo);
  }

    // this shouldn't happen
  if (!dragFlags)
    return (ExitSession(dragFlags));

    // d&d is over, so the DND_DragStatus flags should all be off
  *dragFlags = DND_EXITSESSION;
  if (NS_SUCCEEDED(rv))
    *dragFlags |= DND_DISPATCHEVENT;

    // lie so the client will honor the exit-session flag
  return NS_OK;
}

Here is the call graph for this function:

Definition at line 751 of file nsDragService.cpp.

{
    PR_LOG(sDragLm, PR_LOG_DEBUG, ("nsDragService::ResetDragInfo()"));
    if (nsnull != mDragMessage) delete mDragMessage;
    mDragMessage = NULL;
    mSourceDataItems = NULL;

Here is the caller graph for this function:

nsresult nsDragService::SaveAsContents ( PCSZ  szDest,
nsIURL aURL 
) [protected]

Definition at line 498 of file nsDragService.cpp.

{
  nsCOMPtr<nsIURI> linkURI (do_QueryInterface(aURL));
  if (!linkURI)
    return NS_ERROR_FAILURE;

  nsCOMPtr<nsIWebBrowserPersist> webPersist(
    do_CreateInstance("@mozilla.org/embedding/browser/nsWebBrowserPersist;1"));
  if (!webPersist)
    return NS_ERROR_FAILURE;

  nsCOMPtr<nsILocalFile> file;
  NS_NewNativeLocalFile(nsDependentCString(pszDest), PR_TRUE,
                        getter_AddRefs(file));
  if (!file)
    return NS_ERROR_FAILURE;

  FILE* fp;
  if (NS_FAILED(file->OpenANSIFileDesc("wb+", &fp)))
    return NS_ERROR_FAILURE;

  fwrite("", 0, 1, fp);
  fclose(fp);
  webPersist->SaveURI(linkURI, nsnull, nsnull, nsnull, nsnull, file);

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsDragService::SaveAsText ( PCSZ  szDest,
nsISupportsString aString 
) [protected]

Definition at line 562 of file nsDragService.cpp.

{
  nsAutoString strData;
  aString->GetData(strData);

  if (strData.IsEmpty())
    return NS_ERROR_FAILURE;

  nsCOMPtr<nsILocalFile> file;
  NS_NewNativeLocalFile(nsDependentCString(pszDest), PR_TRUE,
                        getter_AddRefs(file));
  if (!file)
    return NS_ERROR_FAILURE;

  nsXPIDLCString textStr;
  int cnt = UnicodeToCodepage( strData, getter_Copies(textStr));
  if (!cnt)
    return NS_ERROR_FAILURE;

  FILE* fp;
  if (NS_FAILED(file->OpenANSIFileDesc("wb+", &fp)))
    return NS_ERROR_FAILURE;

  fwrite(textStr.get(), cnt, 1, fp);
  fclose(fp);

  nsCOMPtr<nsIDOMDocument> domDoc;
  GetSourceDocument(getter_AddRefs(domDoc));
  SaveTypeAndSource(file, domDoc, "Plain Text");

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsDragService::SaveAsURL ( PCSZ  szDest,
nsIURI aURI 
) [protected]

Definition at line 530 of file nsDragService.cpp.

{
  nsCAutoString strUri;
  aURI->GetSpec(strUri);

  if (strUri.IsEmpty())
    return NS_ERROR_FAILURE;

  nsCOMPtr<nsILocalFile> file;
  NS_NewNativeLocalFile(nsDependentCString(pszDest), PR_TRUE,
                        getter_AddRefs(file));
  if (!file)
    return NS_ERROR_FAILURE;

  FILE* fp;
  if (NS_FAILED(file->OpenANSIFileDesc("wb+", &fp)))
    return NS_ERROR_FAILURE;

  fwrite(strUri.get(), strUri.Length(), 1, fp);
  fclose(fp);

  nsCOMPtr<nsIDOMDocument> domDoc;
  GetSourceDocument(getter_AddRefs(domDoc));
  SaveTypeAndSource(file, domDoc, "UniformResourceLocator");

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 366 of file nsDragService.cpp.

{
    PR_LOG(sDragLm, PR_LOG_DEBUG, ("nsDragService::SetCanDrop(%s)",
                                  aCanDrop == PR_TRUE?"TRUE":"FALSE"));
    return nsBaseDragService::SetCanDrop(aCanDrop);

Here is the caller graph for this function:

Definition at line 1153 of file nsDragService.cpp.

{
  const PRInt32 kCopyCursorID = 144;
  const PRInt32 kLinkCursorID = 145;
  
  // don't do the work if it's the same.
  if ( anAction == mDragAction )
    return NS_OK;
    
  CursHandle newCursor = nsnull;  
  if ( anAction == DRAGDROP_ACTION_COPY )
    newCursor = ::GetCursor ( kCopyCursorID );
  else if ( anAction == DRAGDROP_ACTION_LINK )
    newCursor = ::GetCursor ( kLinkCursorID );
  if ( newCursor ) {
    ::HLock((Handle)newCursor);
    ::SetCursor ( *newCursor );
    ::HUnlock((Handle)newCursor);
  }
  else
    ::InitCursor();
 
  return nsBaseDragService::SetDragAction(anAction);
}

Here is the caller graph for this function:

NS_IMETHODIMP nsDragService::SetDragReference ( QMimeSource *  aDragRef) [virtual]

Since the drag may originate in an external application, we need some way of communicating the QDragObject to the session so it can use it when filling in data requests.

Implements nsIDragSessionQt.

Definition at line 298 of file nsDragService.cpp.

{
   nsMimeStore*  pMimeStore = new nsMimeStore();
   int c = 0;
   const char* format;

   while ((format = aDragRef->format(c++)) != 0) {
     // this is usualy between different processes
     // so, we need to copy datafrom one to onother

     QByteArray ba = aDragRef->encodedData(format);
     pMimeStore->AddFlavorData(format,ba);
   }
   mDragObject = new nsDragObject(pMimeStore,mHiddenWidget);
   return NS_OK;
}

Here is the call graph for this function:

Since the drag may originate in an external application, we need some way of communicating the DragManager's DragRef to the session so it can use it when filling in data requests.

Parameters:
aDragRefthe MacOS DragManager's ref number for the current drag

Implements nsIDragSessionMac.

Definition at line 751 of file nsDragService.cpp.

{
  mDragRef = aDragRef;
  return NS_OK;
  
} // SetDragReference

Definition at line 102 of file nsDragService.cpp.

                                                     {

       if( mRawData ) free( mRawData );

       /* data is the filename used for passing the data */
       FILE *fp = fopen( data, "r" );
       PRUint32 n;
       fread( &n, sizeof( PRUint32 ), 1, fp );
       mRawData = ( char * ) malloc( n );
       if( !mRawData ) { fclose( fp ); return NS_ERROR_FAILURE; }

       fseek( fp, 0, SEEK_SET );
       fread( mRawData, 1, n, fp );
       fclose( fp );

  return NS_OK;
  }

Here is the call graph for this function:

OSErr nsDragService::SetDropFileInDrag ( DragReference  inDragRef,
unsigned int  inItemIndex,
FlavorType  inFlavor,
nsILocalFile inFile 
) [private]

Definition at line 1227 of file nsDragService.cpp.

{
  nsCOMPtr<nsILocalFileMac> targetFileMac = do_QueryInterface(inFile);
  if (!targetFileMac) return paramErr;
  
  FSSpec targetFileSpec;
  nsresult rv = targetFileMac->GetFSSpec(&targetFileSpec);
  if (NS_FAILED(rv)) return paramErr;
  
  return ::SetDragItemFlavorData(inDragRef, inItemIndex, inFlavor, &targetFileSpec, sizeof(FSSpec), 0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsDragService::SetIDataObject ( IDataObject *  aDataObj)

Definition at line 323 of file nsDragService.cpp.

{
  // When the native drag starts the DragService gets
  // the IDataObject that is being dragged
  NS_IF_RELEASE(mDataObject);
  mDataObject = aDataObj;
  NS_IF_ADDREF(mDataObject);

  return NS_OK;
}

Here is the caller graph for this function:

NS_IMETHODIMP nsDragService::SetNativeDndData ( PtWidget_t *  widget,
PhEvent_t *  event 
)

Definition at line 92 of file nsDragService.cpp.

                                                                                    {
       mDndWidget = widget;
       if( !mDndEvent ) {
              mDndEventLen = sizeof( PhEvent_t ) + event->num_rects * sizeof( PhRect_t ) + event->data_len;
              mDndEvent = ( char * ) malloc( mDndEventLen );
              }
       memcpy( mDndEvent, (char*)event, mDndEventLen );
       return NS_OK;
       }

Here is the call graph for this function:

Here is the caller graph for this function:

void nsDragService::SourceDataGet ( GtkWidget *  widget,
GdkDragContext *  context,
GtkSelectionData *  selection_data,
guint  info,
guint32  aTime 
)

Definition at line 1044 of file nsDragService.cpp.

{
  PR_LOG(sDragLm, PR_LOG_DEBUG, ("nsDragService::SourceDataGet"));
  GdkAtom atom = aInfo;
  nsXPIDLCString mimeFlavor;
  gchar *typeName = 0;
  typeName = gdk_atom_name(atom);
  if (!typeName) {
    PR_LOG(sDragLm, PR_LOG_DEBUG, ("failed to get atom name.\n"));
    return;
  }

  PR_LOG(sDragLm, PR_LOG_DEBUG, ("Type is %s\n", typeName));
  // make a copy since |nsXPIDLCString| won't use |g_free|...
  mimeFlavor.Adopt(nsCRT::strdup(typeName));
  g_free(typeName);
  // check to make sure that we have data items to return.
  if (!mSourceDataItems) {
    PR_LOG(sDragLm, PR_LOG_DEBUG, ("Failed to get our data items\n"));
    return;
  }

  if (strcmp(mimeFlavor, gTextUriListType) == 0) {
    // fall back for text/uri-list
    gchar *uriList;
    gint length;

    CreateUriList(mSourceDataItems, &uriList, &length);

    gtk_selection_data_set(aSelectionData, aSelectionData->target,
                           8, (guchar *)uriList, length);
    g_free(uriList);
    return;
  }

  nsCOMPtr<nsISupports> genericItem;
  mSourceDataItems->GetElementAt(0, getter_AddRefs(genericItem));
  nsCOMPtr<nsITransferable> item;
  item = do_QueryInterface(genericItem);
  if (item) {
    // if someone was asking for text/plain, lookup unicode instead so
    // we can convert it.
    PRBool needToDoConversionToPlainText = PR_FALSE;
    const char* actualFlavor = mimeFlavor;
    if (strcmp(mimeFlavor,kTextMime) == 0) {
      actualFlavor = kUnicodeMime;
      needToDoConversionToPlainText = PR_TRUE;
    }
    // if someone was asking for _NETSCAPE_URL we need to convert to
    // plain text but we also need to look for x-moz-url
    else if (strcmp(mimeFlavor, gMozUrlType) == 0) {
      actualFlavor = kURLMime;
      needToDoConversionToPlainText = PR_TRUE;
    }
    else
      actualFlavor = mimeFlavor;

    PRUint32 tmpDataLen = 0;
    void    *tmpData = NULL;
    nsresult rv;
    nsCOMPtr<nsISupports> data;
    rv = item->GetTransferData(actualFlavor, getter_AddRefs(data), &tmpDataLen);
    if (NS_SUCCEEDED(rv)) {
      nsPrimitiveHelpers::CreateDataFromPrimitive (actualFlavor, data,
                                                   &tmpData, tmpDataLen);
      // if required, do the extra work to convert unicode to plain
      // text and replace the output values with the plain text.
      if (needToDoConversionToPlainText) {
        char* plainTextData = nsnull;
        PRUnichar* castedUnicode = NS_REINTERPRET_CAST(PRUnichar*, tmpData);
        PRInt32 plainTextLen = 0;
        nsPrimitiveHelpers::ConvertUnicodeToPlatformPlainText(castedUnicode, 
                                                              tmpDataLen / 2, 
                                                              &plainTextData,
                                                              &plainTextLen);
        if (tmpData) {
          // this was not allocated using glib
          free(tmpData);
          tmpData = plainTextData;
          tmpDataLen = plainTextLen;
        }
      }
      if (tmpData) {
        // this copies the data
        gtk_selection_data_set(aSelectionData, aSelectionData->target,
                               8, (guchar *)tmpData, tmpDataLen);
        // this wasn't allocated with glib
        free(tmpData);
      }
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsDragService::SourceDataGet ( GtkWidget *  widget,
GdkDragContext *  context,
GtkSelectionData *  selection_data,
guint  info,
guint32  aTime 
)

Definition at line 975 of file nsDragService.cpp.

{
  // this just releases the list of data items that we provide
  mSourceDataItems = 0;

  // Inform the drag session that we're ending the drag.
  EndDragSession();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 332 of file nsDragService.cpp.

{
    PR_LOG(sDragLm, PR_LOG_DEBUG, ("nsDragService::StartDragSession()"));
    return nsBaseDragService::StartDragSession();

Here is the caller graph for this function:

Tells the Drag Service to start a drag session.

This is called when an external drag occurs

NS_IMETHODIMP nsDragService::StartInvokingDragSession ( IDataObject *  aDataObj,
PRUint32  aActionType 
)

Definition at line 156 of file nsDragService.cpp.

{
  // To do the drag we need to create an object that
  // implements the IDataObject interface (for OLE)
  NS_IF_RELEASE(mNativeDragSrc);
  mNativeDragSrc = (IDropSource *)new nsNativeDragSource();
  if (!mNativeDragSrc)
    return NS_ERROR_OUT_OF_MEMORY;

  mNativeDragSrc->AddRef();

  // Now figure out what the native drag effect should be
  DWORD dropRes;
  DWORD effects = DROPEFFECT_SCROLL;
  if (aActionType & DRAGDROP_ACTION_COPY) {
    effects |= DROPEFFECT_COPY;
  }
  if (aActionType & DRAGDROP_ACTION_MOVE) {
    effects |= DROPEFFECT_MOVE;
  }
  if (aActionType & DRAGDROP_ACTION_LINK) {
    effects |= DROPEFFECT_LINK;
  }

  // XXX not sure why we bother to cache this, it can change during
  // the drag
  mDragAction = aActionType;
  mDoingDrag  = PR_TRUE;

  // Start dragging
  StartDragSession();

  // Call the native D&D method
  HRESULT res = ::DoDragDrop(aDataObj, mNativeDragSrc, effects, &dropRes);

  // We're done dragging
  EndDragSession();

  // For some drag/drop interactions, IDataObject::SetData doesn't get
  // called with a CFSTR_PERFORMEDDROPEFFECT format and the
  // intermediate file (if it was created) isn't deleted.  See
  // http://bugzilla.mozilla.org/show_bug.cgi?id=203847#c4 for a
  // detailed description of the different cases.  Now that we know
  // that the drag/drop operation has ended, call SetData() so that
  // the intermediate file is deleted.
  static CLIPFORMAT PerformedDropEffect =
    ::RegisterClipboardFormat(CFSTR_PERFORMEDDROPEFFECT);

  FORMATETC fmte =
    {
      (CLIPFORMAT)PerformedDropEffect,
      NULL,
      DVASPECT_CONTENT,
      -1,
      TYMED_NULL
    };

  STGMEDIUM medium;
  medium.tymed = TYMED_NULL;
  medium.pUnkForRelease = NULL;
  aDataObj->SetData(&fmte, &medium, FALSE);

  mDoingDrag = PR_FALSE;

  return DRAGDROP_S_DROP == res ? NS_OK : NS_ERROR_FAILURE;
}

Here is the call graph for this function:

Increase/decrease dragging suppress level by one.

If level is greater than one, dragging is disabled.

NS_IMETHOD nsDragService::TargetDataReceived ( GtkWidget *  aWidget,
GdkDragContext *  aContext,
gint  aX,
gint  aY,
GtkSelectionData *  aSelection_data,
guint  aInfo,
guint32  aTime 
) [virtual]

Implements nsIDragSessionGTK.

NS_IMETHODIMP nsDragService::TargetDataReceived ( GtkWidget *  aWidget,
GdkDragContext *  aContext,
gint  aX,
gint  aY,
GtkSelectionData *  aSelection_data,
guint  aInfo,
guint32  aTime 
) [virtual]

Implements nsIDragSessionGTK.

Definition at line 717 of file nsDragService.cpp.

{
  PR_LOG(sDragLm, PR_LOG_DEBUG, ("nsDragService::TargetDataReceived"));
  TargetResetData();
  mTargetDragDataReceived = PR_TRUE;
  if (aSelectionData->length > 0) {
    mTargetDragDataLen = aSelectionData->length;
    mTargetDragData = g_malloc(mTargetDragDataLen);
    memcpy(mTargetDragData, aSelectionData->data, mTargetDragDataLen);
  }
  else {
    PR_LOG(sDragLm, PR_LOG_DEBUG,
           ("Failed to get data.  selection data len was %d\n",
            aSelectionData->length));
  }
  return NS_OK;
}

Here is the call graph for this function:

NS_IMETHOD nsDragService::TargetEndDragMotion ( GtkWidget *  aWidget,
GdkDragContext *  aContext,
guint  aTime 
) [virtual]

Implements nsIDragSessionGTK.

NS_IMETHODIMP nsDragService::TargetEndDragMotion ( GtkWidget *  aWidget,
GdkDragContext *  aContext,
guint  aTime 
) [virtual]

Implements nsIDragSessionGTK.

Definition at line 687 of file nsDragService.cpp.

{
  PR_LOG(sDragLm, PR_LOG_DEBUG, ("nsDragService::TargetEndDragMotion %d", mCanDrop));

  if (mCanDrop) {
    GdkDragAction action;
    // notify the dragger if we can drop
    switch (mDragAction) {
    case DRAGDROP_ACTION_COPY:
      action = GDK_ACTION_COPY;
      break;
    case DRAGDROP_ACTION_LINK:
      action = GDK_ACTION_LINK;
      break;
    default:
      action = GDK_ACTION_MOVE;
      break;
    }
    gdk_drag_status(aContext, action, aTime);
  }
  else {
    gdk_drag_status(aContext, (GdkDragAction)0, aTime);
  }

  return NS_OK;
}

Definition at line 809 of file nsDragService.cpp.

{
  mTargetDragDataReceived = PR_FALSE;
  // make sure to free old data if we have to
  if (mTargetDragData)
    g_free(mTargetDragData);
  mTargetDragData = 0;
  mTargetDragDataLen = 0;
}

Here is the caller graph for this function:

NS_IMETHODIMP nsDragService::TargetSetLastContext ( GtkWidget *  aWidget,
GdkDragContext *  aContext,
guint  aTime 
) [virtual]

Implements nsIDragSessionGTK.

Definition at line 667 of file nsDragService.cpp.

{
  PR_LOG(sDragLm, PR_LOG_DEBUG, ("nsDragService::TargetSetLastContext"));
  mTargetWidget = aWidget;
  mTargetDragContext = aContext;
  mTargetTime = aTime;
  return NS_OK;
}
NS_IMETHOD nsDragService::TargetSetLastContext ( GtkWidget *  aWidget,
GdkDragContext *  aContext,
guint  aTime 
) [virtual]

Implements nsIDragSessionGTK.

Implements nsIDragSessionGTK.

Implements nsIDragSessionGTK.

Definition at line 742 of file nsDragService.cpp.

{
  PR_LOG(sDragLm, PR_LOG_DEBUG, ("nsDragService::TargetSetTimeCallback"));
  mTimeCB = aCallback;
  return NS_OK;
}

Implements nsIDragSessionGTK.

Implements nsIDragSessionGTK.

Definition at line 679 of file nsDragService.cpp.

{
  PR_LOG(sDragLm, PR_LOG_DEBUG, ("nsDragService::TargetStartDragMotion"));
  mCanDrop = PR_FALSE;
  return NS_OK;
}
NS_IMETHODIMP nsDragService::TransmitData ( BMessage *  aNegotiationReply) [virtual]

Implements nsIDragSessionBeOS.

Definition at line 712 of file nsDragService.cpp.

{
    PR_LOG(sDragLm, PR_LOG_DEBUG, ("nsDragService::TransmitData()"));
/*
    unsigned int numDragItems = 0;
    mSourceDataItems->Count(&numDragItems);
    
    returnMsg->AddString("be:originator", "BeZilla");
    returnMsg->AddString("be:clip_name","BeZilla Drag Item");
  
    // Check to see if we're dragging > 1 item.  If we are then we use
    // an internal only type.
    if (numDragItems > 1)
    {
        PR_LOG(sDragLm, PR_LOG_DEBUG, ("nsDragService:: Dragging a list of items ..."));
        delete aNegotiationReply;
        return;
    }
    BMessage aReply = new BMessage(B_MIME_DATA);
    char * aMimeType;
    aNegotiationReply->FindString("be:types", &aMimeType);
     nsCOMPtr<nsITransferable> item;
     item->addDataFlavor(aMimeType);
    GetData(item, 0);
    aReply->AddData(aMimeType, item->);
  */  
    aNegotiationReply->PrintToStream();
    delete aNegotiationReply;
    return NS_OK;
NS_IMETHODIMP nsDragService::UpdateDragMessageIfNeeded ( BMessage *  aDragMessage) [virtual]

Implements nsIDragSessionBeOS.

Definition at line 682 of file nsDragService.cpp.

{
    PR_LOG(sDragLm, PR_LOG_DEBUG, ("nsDragService::UpdateDragMessageIfNeeded()"));
    if (aDragMessage == mDragMessage) 
        return NS_OK;
    
    // Did we start this drag?
    //It's already set properly by InvokeDragSession, so don't do anything and avoid throwing away
    //mSourceDataItems
    if (IsInternalDrag(aDragMessage))
        return NS_OK;

    PR_LOG(sDragLm, PR_LOG_DEBUG, ("updating."));
    ResetDragInfo();
    mDragMessage = aDragMessage;
    return NS_OK;

Here is the call graph for this function:

Implements nsIDragSessionXlib.

Definition at line 254 of file nsDragService.cpp.

{
  if (sWindow) {
    Window aRoot, aChild;
    int cx, cy;
    unsigned int mask;
    XQueryPointer(sDisplay, sWindow, &aRoot, &aChild, &x, &y, &cx, &cy, &mask); 
    XMoveWindow(sDisplay, sWindow, x, y);
  }
  return NS_OK;
}

Friends And Related Function Documentation

MRESULT EXPENTRY nsDragWindowProc ( HWND  hWnd,
ULONG  msg,
MPARAM  mp1,
MPARAM  mp2 
) [friend]

Definition at line 264 of file nsDragService.cpp.

{
  switch (msg) {

      // if the user requests the contents of a URL be rendered (vs the URL
      // itself), change the suggested target name from the URL's title to
      // the name of the file that will be retrieved
    case DM_RENDERPREPARE: {
      PDRAGTRANSFER  pdxfer = (PDRAGTRANSFER)mp1;
      nsDragService* dragservice = (nsDragService*)pdxfer->pditem->ulItemID;
  
      if (pdxfer->usOperation == DO_COPY &&
          (WinGetKeyState(HWND_DESKTOP, VK_CTRL) & 0x8000) &&
          !strcmp(dragservice->mMimeType, kURLMime)) {
          // QI'ing nsIURL will fail for mailto: and the like
        nsCOMPtr<nsIURL> urlObject(do_QueryInterface(dragservice->mSourceData));
        if (urlObject) {
          nsCAutoString filename;
          urlObject->GetFileName(filename);
          if (filename.IsEmpty()) {
            urlObject->GetHost(filename);
            filename.Append("/file");
          }
          DrgDeleteStrHandle(pdxfer->pditem->hstrTargetName);
          pdxfer->pditem->hstrTargetName = DrgAddStrHandle(filename.get());
        }
      }
      return (MRESULT)TRUE;
    }
  
    case DM_RENDER: {
      nsresult       rv = NS_ERROR_FAILURE;
      PDRAGTRANSFER  pdxfer = (PDRAGTRANSFER)mp1;
      nsDragService* dragservice = (nsDragService*)pdxfer->pditem->ulItemID;
      char           chPath[CCHMAXPATH];

      DrgQueryStrName(pdxfer->hstrRenderToName, CCHMAXPATH, chPath);

        // if the user Ctrl-dropped a URL, use the nsIURL interface
        // to determine if it points to content (i.e. a file);  if so,
        // fetch its contents; if not (e.g. a 'mailto:' url), drop into
        // the code that uses nsIURI to render a URL object

      if (!strcmp(dragservice->mMimeType, kURLMime)) {
        if (pdxfer->usOperation == DO_COPY &&
            (WinGetKeyState(HWND_DESKTOP, VK_CTRL) & 0x8000)) {
          nsCOMPtr<nsIURL> urlObject(do_QueryInterface(dragservice->mSourceData));
          if (urlObject)
            rv = dragservice->SaveAsContents(chPath, urlObject);
        }
        if (!NS_SUCCEEDED(rv)) {
          nsCOMPtr<nsIURI> uriObject(do_QueryInterface(dragservice->mSourceData));
          if (uriObject)
            rv = dragservice->SaveAsURL(chPath, uriObject);
        }
      }
      else
          // if we're dragging text, do NLS conversion then write it to file
        if (!strcmp(dragservice->mMimeType, kUnicodeMime)) {
          nsCOMPtr<nsISupportsString> strObject(
                                 do_QueryInterface(dragservice->mSourceData));
          if (strObject)
            rv = dragservice->SaveAsText(chPath, strObject);
        }
  
      DrgPostTransferMsg(pdxfer->hwndClient, DM_RENDERCOMPLETE, pdxfer,
                         (NS_SUCCEEDED(rv) ? DMFL_RENDEROK : DMFL_RENDERFAIL),
                         0, TRUE);
      DrgFreeDragtransfer(pdxfer);
      return (MRESULT)TRUE;
    }

      // we don't use these msgs but neither does WinDefWindowProc()
    case DM_DRAGOVERNOTIFY:
    case DM_ENDCONVERSATION:
      return 0;
  
    default:
      break;
  }

  return ::WinDefWindowProc(hWnd, msg, mp1, mp2);
}

Member Data Documentation

Set the current state of the drag whether it can be dropped or not.

usually the target "frame" sets this so the native system can render the correct feedback

Definition at line 62 of file nsIDragSession.idl.

Sets the action (copy, move, link, et.c) for the current drag.

Definition at line 67 of file nsIDragSession.idl.

Definition at line 53 of file nsIDragService.idl.

Definition at line 55 of file nsIDragService.idl.

Definition at line 54 of file nsIDragService.idl.

Definition at line 52 of file nsIDragService.idl.

BString nsDragService::gMimeListType [private]

Definition at line 97 of file nsDragService.h.

Definition at line 75 of file nsDragService.h.

Reimplemented from nsBaseDragService.

Definition at line 122 of file nsDragService.h.

Definition at line 106 of file nsDragService.h.

IDataObject* nsDragService::mDataObject [protected]

Definition at line 84 of file nsDragService.h.

char* nsDragService::mDndEvent [static, private]

Definition at line 79 of file nsDragService.h.

int nsDragService::mDndEventLen [static, private]

Definition at line 80 of file nsDragService.h.

PtWidget_t* nsDragService::mDndWidget [private]

Definition at line 78 of file nsDragService.h.

Definition at line 79 of file nsBaseDragService.h.

PRUint32 nsBaseDragService::mDragAction [protected, inherited]

Definition at line 80 of file nsBaseDragService.h.

Definition at line 93 of file nsDragService.h.

Definition at line 99 of file nsDragService.h.

BMessage* nsDragService::mDragMessage [private]

Definition at line 91 of file nsDragService.h.

QDragObject* nsDragService::mDragObject [private]

Definition at line 83 of file nsDragService.h.

Definition at line 105 of file nsDragService.h.

DragSendDataUPP nsDragService::mDragSendDataUPP [private]

Definition at line 104 of file nsDragService.h.

Definition at line 97 of file nsDragService.h.

Definition at line 96 of file nsDragService.h.

char * nsDragService::mFlavourStr [private]

Definition at line 84 of file nsDragService.h.

QWidget* nsDragService::mHiddenWidget [private]

Definition at line 82 of file nsDragService.h.

GtkWidget * nsDragService::mHiddenWidget [private]

Definition at line 139 of file nsDragService.h.

Definition at line 109 of file nsDragService.h.

char* nsDragService::mMimeType [protected]

Definition at line 98 of file nsDragService.h.

PtTransportCtrl_t* nsDragService::mNativeCtrl [private]

Definition at line 83 of file nsDragService.h.

IDropSource* nsDragService::mNativeDragSrc [protected]

Definition at line 82 of file nsDragService.h.

Definition at line 83 of file nsDragService.h.

char* nsDragService::mRawData [private]

Definition at line 84 of file nsDragService.h.

nsCOMPtr<nsISupports> nsDragService::mSourceData [protected]

Definition at line 100 of file nsDragService.h.

Definition at line 85 of file nsDragService.h.

Definition at line 84 of file nsBaseDragService.h.

Definition at line 83 of file nsBaseDragService.h.

Definition at line 86 of file nsBaseDragService.h.

GdkDragContext * nsDragService::mTargetDragContext [private]

Definition at line 119 of file nsDragService.h.

Definition at line 126 of file nsDragService.h.

Definition at line 127 of file nsDragService.h.

Definition at line 124 of file nsDragService.h.

nsSize nsBaseDragService::mTargetSize [protected, inherited]

Definition at line 81 of file nsBaseDragService.h.

guint nsDragService::mTargetTime [private]

Definition at line 120 of file nsDragService.h.

GtkWidget * nsDragService::mTargetWidget [private]

Definition at line 118 of file nsDragService.h.

Definition at line 146 of file nsDragService.h.

Definition at line 82 of file nsBaseDragService.h.

Definition at line 84 of file nsDragService.h.

readonly attribute unsigned long nsIDragSession::numDropItems [inherited]

Get the number items that were dropped.

Definition at line 78 of file nsIDragSession.idl.

Display * nsDragService::sDisplay [static, private]

Definition at line 92 of file nsDragService.h.

The document where the drag was started, which will be null if the drag originated outside the application.

Useful for determining if a drop originated in the same document.

Definition at line 85 of file nsIDragSession.idl.

The dom node that was originally dragged to start the session, which will be null if the drag originated outside the application.

Definition at line 91 of file nsIDragSession.idl.

nsWidget * nsDragService::sWidget = nsnull [static, private]

Definition at line 89 of file nsDragService.h.

Window nsDragService::sWindow [static, private]

Definition at line 90 of file nsDragService.h.

XlibRgbHandle * nsDragService::sXlibRgbHandle [static, private]

Definition at line 91 of file nsDragService.h.

Sets the current width and height if the drag target area.

It will contain the current size of the Frame that the drag is currently in

Definition at line 73 of file nsIDragSession.idl.


The documentation for this class was generated from the following files: