Example #1
0
int
XFE_ABDirListView::ProcessTargets(int row, int col,
								  Atom *targets,
								  const char **data,
								  int numItems)
{
	int i;

	D(("XFE_ABDirListView::ProcessTargets(row=%d, col=%d, numItems=%d)\n", row, col, numItems));
	
	for (i=0; i < numItems; i++) {
		if (targets[i]==None || data[i]==NULL || strlen(data[i])==0)
			continue;
		
		D(("  [%d] %s: \"%s\"\n",i,XmGetAtomName(XtDisplay(m_widget),targets[i]),data[i]));
		if (targets[i] == XFE_OutlinerDrop::_XA_NETSCAPE_DIRSERV) {
#if defined(DEBUG_tao)
			printf("\nXFE_ABDirListView::ProcessTargets:_XA_NETSCAPE_DIRSERV\n");
#endif		
			/* decode
			 */			
			char *pStr = (char *) XP_STRDUP(data[i]);
			int   len = XP_STRLEN(pStr);

			uint32 pCount = 0;
			char tmp[32];
			sscanf(data[i], "%d", &pCount);
			int *indices = (int *) XP_CALLOC(pCount, sizeof(int));
			
			char *tok = 0,
			     *last = 0;
			int   count = 0;
			char *sep = " ";

			while (((tok=XP_STRTOK_R(count?nil:pStr, sep, &last)) != NULL)&&
				   XP_STRLEN(tok) &&
				   count < len) {
				int index = atoi(tok);
				if (!count)
					XP_ASSERT(index == pCount);
				else
					indices[count-1] = 	index;
				count++;
			}/* while */
			return TRUE;
		}/* if */
		else if (targets[i] == XFE_OutlinerDrop::_XA_NETSCAPE_PAB) {
			D(("  [%d] %s: \"%s\"\n",i,XmGetAtomName(XtDisplay(m_widget),targets[i]),data[i]));
#if defined(DEBUG_tao)
			printf("\nXFE_ABDirListView::ProcessTargets:_XA_NETSCAPE_PAB\n");
#endif
			return TRUE;
		}/* elss if */	
	}/* for i */
	return FALSE;
}
Example #2
0
int XFE_ComposeAttachDrop::processTargets(Atom *targets,const char **data,int numItems)
{
    XDEBUG(printf("XFE_ComposeAttachDrop::processTargets()\n"));
    
    if (!targets || !data || numItems==0)
        return FALSE;

    // pass dropped data to attachment panel

    char **dropInfo=new char*[numItems];
    int numDropInfo=0;
    int i;
    
    for (i=0;i<numItems;i++) {
        if (targets[i]==None || data[i]==NULL || strlen(data[i])==0)
            continue;

        XDEBUG(printf("  [%d] %s: \"%s\"\n",i,XmGetAtomName(XtDisplay(_widget),targets[i]),data[i]));

        if (targets[i]==_XA_FILE_NAME) {
            dropInfo[numDropInfo++]=XP_STRDUP(data[i]);
        }
        if (targets[i]==_XA_NETSCAPE_URL) {
            XFE_URLDesktopType urlData(data[i]);
            for (int j=0;j<urlData.numItems();j++) {
                dropInfo[numDropInfo++]=XP_STRDUP(urlData.url(j));
            }
        }
        if (targets[i]==XA_STRING) {
            dropInfo[numDropInfo++]=XP_STRDUP(data[i]);
        }
    }
    
    int dropStatus=_attachPanel->dropAttachments((const char **)dropInfo,numDropInfo);

    // free drop info
    for(i=0;i<numDropInfo; i++)
        if (dropInfo[i])
            XP_FREE(dropInfo[i]);
    delete dropInfo;
    
    return dropStatus;
}