Esempio n. 1
0
//----------------------------------------------------------------------------
// Save a data stream to file
//
// pFile will contain "device path,pc folder" of which we want the 'pc folder' part
int CSTATEngine::SaveTransferFile(const char *pFile, char *pContents, unsigned long ulLength)
{
	int ret = E_BADFILENAME;

	CString path = ST_WORKINGPATH_VALUE;
	//read from inifile if entry exists
	if(statIniFile.SectionExists(ST_TEST_KEY) )
	{
		CString setting;
		setting.Empty();
		setting=statIniFile.GetKeyValue(ST_WORKINGPATH,ST_TEST_KEY);
		if(!setting.IsEmpty())
			path = setting;
	}
	// add a backslash
	if (path.Right(1) != _T('\\'))
		path += _T('\\');

	// get any additional sub folders
	CString folder = pFile;
	int index = folder.Find(_T(','));
	if (index == -1)
		return E_BADFILENAME;
	// if the comma is the last char there are no folders to add
	if (folder.Right(1) != _T(','))
	{
		path += folder.Mid(index + 1);

		// add a backslash
		if (path.Right(1) != _T('\\'))
			path += _T('\\');
	}

	if (bMultithreaded)
	{
		// add a sub-folder for the connection type
		path += GetConnection(eConnectType);
		path += _T(".");
		path += szAddress;
		path += _T('\\');
	}

	// now extract the filename from the first argument
	CString filename = folder.Left(index);
	index = filename.ReverseFind(_T('\\'));
	if (index == -1)
		path += filename;
	else
		path += filename.Mid(index + 1);

	Message("Saving file [%s]", ToAnsi(path));

	ret = SaveTheFile(path, pContents, ulLength);
	if (ret != ITS_OK)
		Message("Error saving [%s] (%d)", ToAnsi(path), GetLastError());
	return ret;
}
Esempio n. 2
0
/*
 * Class:     sunw_util_AZJni_SendStringClass
 * Method:    sendString
 * Signature: (Ljava/lang/String;Ljava/lang/String;)V
 */
JNIEXPORT void JNICALL Java_sunw_util_AZJni_00024SendStringClass_sendString
  (JNIEnv* env, jclass, jstring nameWindow, jstring chars)
{
	DbgMsg("Enter from java");
	char* nameWindow2 = ToAnsi( (WCHAR*)env->GetStringChars( nameWindow, NULL ) );
	char* chars2 = ToAnsi( (WCHAR*)env->GetStringChars( chars, NULL ) );
	SendKeys( nameWindow2, chars2 );
	u_free(nameWindow2);
	u_free(chars2);
}
bool CSkeletonActionExpDlg::InsertActionToUI(sActionInfo_t& action)
{
	int index = findAction(action.m_Name);

	if(index != -1 && !m_bHasUI )
	{
		return false;
	}
	char buf[23];
	sprintf(buf,"%d",index);
	m_ctrlActionList.InsertItem(index,buf);
	m_ctrlActionList.SetItemText(index,1,ToAnsi(action.m_Name).c_str() );

	sprintf(buf,"%d",action.m_lTime);
	m_ctrlActionList.SetItemText(index,2,buf);

	sprintf(buf,"%d",action.m_iFirstFrame);
	m_ctrlActionList.SetItemText(index,3,buf);

	sprintf(buf,"%d",action.m_iLastFrame);
	m_ctrlActionList.SetItemText(index,4,buf);
	return true;
}
Esempio n. 4
0
//----------------------------------------------------------------------------
// Read in a file's contents
//
// pFile will contain "pc path,device path" of which we want the 'pc path' part
int CSTATEngine::ReadTransferFile(const char *pFile, CSTATScriptCommand *pCommand)
{
	int ret = E_BADFILENAME;

	// get the default file location
	CString path = ST_WORKINGPATH_VALUE;
	//read from inifile if entry exists
	if(statIniFile.SectionExists(ST_TEST_KEY) )
	{
		CString setting;
		setting.Empty();
		setting=statIniFile.GetKeyValue(ST_WORKINGPATH,ST_TEST_KEY);
		if(!setting.IsEmpty())
			path = setting;
	}

	// add a backslash
	if (path.Right(1) != _T('\\'))
		path += _T('\\');

	// get the name of the file
	CString filename = pFile;
	int index = filename.ReverseFind(_T(','));
	if (index == -1)
		return E_BADFILENAME;

	// add the name
	path += filename.Left(index);

	Message("Opening file [%s]", ToAnsi(path));

	EnterCriticalSection(&CriticalSection);

	CFile script_file;
	if (script_file.Open(path, CFile::modeRead))
	{
		try
		{
			char *pData = new char [script_file.GetLength()];
			if (pData)
			{
				script_file.Read(pData, script_file.GetLength());

				if(pCommand->SetData(pData, script_file.GetLength()))
					ret = ITS_OK;
				else
					ret = E_OUTOFMEM;

				delete [] pData;
			}
			else
				ret = E_OUTOFMEM;
		}
		catch(CFileException *e)
		{
			e->Delete();
			ret = GENERAL_FAILURE;
		}

		script_file.Abort();
	}

	LeaveCriticalSection(&CriticalSection);
	return ret;
}
Esempio n. 5
0
int WINAPI JsonPlugin::ConfigureW(const ConfigureInfo *info)
{
    if(info->StructSize > sizeof *info /*|| memcmp(info->Guid, &MenuGuid, sizeof MenuGuid)*/)
        return FALSE;
#else
int WINAPI JsonPlugin::EXP_NAME(Configure)(int)
{
#endif

#if 0
 static FarDialogItemID DialogItems[]={
    /*00*/{DI_DOUBLEBOX,3,1,72,13,0,0,0,0,MOptions},
    /*01*/{DI_TEXT,5,2,0,0,0,0,0,0,MExportFormat},
    /*02*/{DI_RADIOBUTTON,5,3,0,0,0,0,DIF_GROUP,0,MExportUTF8},
    /*03*/{DI_RADIOBUTTON,5,4,0,0,0,0,0,0, MExportWin},
    /*04*/{DI_TEXT,4,5,0,0,0,0,DIF_SEPARATOR},
    /*05*/{DI_CHECKBOX,5,6,0,0,0,0,0,0,MAddPluginsMenu},
    /*06*/{DI_CHECKBOX,5,7,0,0,0,0,0,0,MEnableFileOpening},
    /*07*/{DI_CHECKBOX,5,8,0,0,0,0,0,0,MValidateOnParse},
    /*08*/{DI_CHECKBOX,40,8,0,0,0,0,0,0,MResolveExternals},    
    /*09*/{DI_CHECKBOX,5,9,0,0,0,0,0,0,MStartUnsorted},
    /*10*/{DI_TEXT,5,10,0,0,0,0,0,0,MNameAttributes},
    /*11*/{DI_EDIT,40,10,70},
    /*12*/{DI_TEXT,4,11,0,0,0,0,DIF_SEPARATOR},
    /*13*/{DI_BUTTON,0,12,0,0,0,0,DIF_CENTERGROUP,1,MOK},
    /*14*/{DI_BUTTON,0,12,0,0,0,0,DIF_CENTERGROUP,0,MCancel},
    /*15*/{DI_BUTTON,0,12,0,0,0,0,DIF_BTNNOCLOSE|DIF_CENTERGROUP,0,MOverrideColumns},
  };
  extern TCHAR sExportUTF[];
  USE_SETTINGSW;
  bExportUTF = settings.Get(sExportUTF, 1);
  bStartUnsorted = settings.Get(sStartUnsorted, 1);
  DialogItems[2].Selected = bExportUTF;
  DialogItems[3].Selected = !bExportUTF;
  DialogItems[5].Selected = settings.Get(sAddPluginsMenu, 0);
  DialogItems[6].Selected = settings.Get(sBrowseXMLFiles, 1);
  DialogItems[7].Selected = settings.Get(sValidateOnParse, 0);
  DialogItems[8].Selected = settings.Get(sResolveExternals, 0);  
  DialogItems[9].Selected = settings.Get(sStartUnsorted, 1);  

#ifdef FAR3
  PanelInfo panel;
  StartupInfo.PanelControl(PANEL_ACTIVE, FCTL_GETPANELINFO, 0, &panel);
  int itemCount = _countof(DialogItems) - (panel.PluginHandle == 0);
#else
  int itemCount = _countof(DialogItems) - 1;
#endif
  FarDialogItem* ItemsStr = MakeDialogItems(DialogItems, itemCount);

  extern TCHAR sIdAttributes[], sDefIdAttributes[];
#ifdef UNICODE
  wchar_t attrlist[512];
  DWORD attrsize = _countof(attrlist)-1;
  attrlist[attrsize] = 0;
#else
  char* attrlist = ItemsStr[11].Data;
  DWORD attrsize = sizeof ItemsStr[11].Data-1;
#endif
  SetData(ItemsStr[11], attrlist, attrsize);
  settings.Get(sIdAttributes, attrlist, attrsize, sDefIdAttributes);
  ToOem(ItemsStr[10].Data);
  ItemsStr[11].X1 = ItemsStr[10].X1 + _tcslen(ItemsStr[10].ITEMDATA)+1;

  RUN_DIALOG(ConfigDialogGuid, -1, -1, 76, 15, _T("Config"), ItemsStr, itemCount);
  if(DIALOG_RESULT != 13 /*OK*/) {
    delete ItemsStr;
    return FALSE;
  }
  bExportUTF = GetSelected(ItemsStr,2);
  bStartUnsorted = GetSelected(ItemsStr,9);
  ToAnsi(ItemsStr[11].Data);
  settings.Set(sIdAttributes, GetItemText(ItemsStr,11));
  settings.Set(sExportUTF, bExportUTF);
  settings.Set(sAddPluginsMenu, GetSelected(ItemsStr,5));
  settings.Set(sBrowseXMLFiles, GetSelected(ItemsStr,6));
  settings.Set(sValidateOnParse, GetSelected(ItemsStr,7));
  settings.Set(sResolveExternals, GetSelected(ItemsStr,8));
  settings.Set(sStartUnsorted, bStartUnsorted);

  XMLPlugin::LoadIdAttributes();
  delete ItemsStr;

  return TRUE;
#endif

  return FALSE;
}

int
#ifndef FAR3
    WINAPI
#endif
           EXP_NAME(Compare)(HANDLE hPlugin,const struct PluginPanelItem *Item1,const struct PluginPanelItem *Item2,
                                                    unsigned int Mode)
{
    switch(Mode)
    {
        case SM_NAME:
        case SM_EXT:
            {
#ifndef UNICODE
            return mystrcmpi(Item1->FindData.cFileName, Item2->FindData.cFileName);
#else
            PCWSTR s1 = Item1->FileName;
            PCWSTR s2 = Item2->FileName;
            return lstrcmpi(s1,s2);
#endif
            }
        default:
            return -2;
    }
}

#ifdef FAR3
intptr_t WINAPI CompareW(const CompareInfo *info)
{
    if(info->StructSize < sizeof(CompareInfo))
        return -2;
    return CompareW(info->hPanel, info->Item1, info->Item2, info->Mode);
}
#endif

#ifdef FAR3
int WINAPI JsonPlugin::EXP_NAME(ProcessDialogEvent)(const ProcessDialogEventInfo *info)
{
#if 0
    if(info->StructSize != sizeof(ProcessDialogEventInfo) || info->Event != DE_DLGPROCINIT)
        return FALSE;
    FarDialogEvent& evt = *(FarDialogEvent *)info->Param;
    if(evt.Msg == DN_BTNCLICK && evt.Param1 == 15/*Override button*/)
    {
        PanelInfo panel;
        Control(FCTL_GETPANELINFO, 0, &panel);
        if(!panel.PluginHandle || panel.OwnerGuid != PluginGuid)
            return FALSE;
        ((JsonPlugin*)panel.PluginHandle)->EditSpecialDocs();
        return TRUE;
    }
#endif
    return FALSE;
}