// OpenDepot.cpp : Implementation of OpenDepot #include "stdafx.h" #include "OpenDepot.h" #include "OpenDepotDialog.h" #include "P4DialogPluginHost.h" #include "StrBufArray.h" #include "PerforceConnection.h" // OpenDepot HINSTANCE hInstance; // Required in lib file. StrBufArray *ConvertVariantToArray(const VARIANT &newVal) { USES_CONVERSION; if (!(newVal.vt & VT_ARRAY) || !(newVal.vt & VT_BSTR)) return NULL; StrBufArray *result = new StrBufArray(); // // Extract the SAFEARRAY // SAFEARRAY *pArray; if (newVal.vt & VT_BYREF) pArray = *(newVal.pparray); // VBScript else pArray = newVal.parray; // VB // // Read the data. // if (pArray->fFeatures & FADF_VARIANT) // SAFEARRAY of VARIANTS, i.e. VBScript. { VARIANT *bvarArray; ::SafeArrayAccessData (pArray, (void **)&bvarArray); for (unsigned int i = 0; i < pArray->rgsabound->cElements; i++) { if (bvarArray[i].vt != VT_NULL && bvarArray[i].vt != VT_EMPTY && bvarArray[i].vt == VT_BSTR ) { result->Put(W2T(bvarArray[i].bstrVal)); } } ::SafeArrayUnaccessData(pArray); } else if (pArray->fFeatures & FADF_BSTR) // SAFEARRAY of BSTRs, i.e. VB. { BSTR *bstrArray; ::SafeArrayAccessData (pArray, (void **)&bstrArray); for (unsigned int i = 0; i < pArray->rgsabound->cElements; i++) { result->Put(W2T(bstrArray[i])); } ::SafeArrayUnaccessData(pArray); } else return NULL; return result; } STDMETHODIMP OpenDepot::Run(long hWnd, VARIANT fileTypesVariant, BSTR* selectedFile) { StrBufArray *fileTypes = ConvertVariantToArray(fileTypesVariant); HINSTANCE hInst = (HINSTANCE) _AtlBaseModule.m_hInst; P4DialogPluginHost *host = new P4DialogPluginHost(hInst, (HWND) hWnd); PerforceOptions *options = new PerforceOptions(_T("P4Dialogs")); PluginOperations *operations = new PluginOperations(host); try { SetLastError(0); OpenDepotDialog dialog( operations, options, fileTypes ); dialog.SetCaption(_T("P4OFC - Get Latest Revision from Perforce")); if ( dialog.Show( host->GetInstance(), host->GetWin() ) == TRUE ) { StrPtr *clientFile = dialog.SelectedFile(); if ( clientFile != NULL ) { CComBSTR result = (TCHAR *)clientFile->Text(); *selectedFile = result.Detach(); } } if (NULL != fileTypes) { delete fileTypes; } } catch ( std::exception e ) { return Error(e.what(), GUID_NULL, MAKE_HRESULT(SEVERITY_ERROR, FACILITY_NULL, 1)); } return S_OK; } STDMETHODIMP OpenDepot::InterfaceSupportsErrorInfo(REFIID riid) { static const IID* arr[] = { &IID_IOpenDepot }; for (int i=0; i < sizeof(arr) / sizeof(arr[0]); i++) { if (InlineIsEqualGUID(*arr[i],riid)) return S_OK; } return S_FALSE; }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 11314 | Robert Cowham | Initial population of perforce_software version of P4OFC | ||
//guest/robert_cowham/perforce/P4OFC/main/p4dialogs/OpenDepot.cpp | |||||
#1 | 10843 | Robert Cowham |
Initial version of P4OFC source code. See README.txt (and LICENSE.txt and doc\P4OFC-Design.docx) |