2017-10-06 17:20:58 +02:00
// Decompiled with JetBrains decompiler
// Type: CarotDAV.CarotDAVDataObject
// Assembly: CarotDAV, Version=1.13.2.18337, Culture=neutral, PublicKeyToken=null
// MVID: C31F2651-A4A8-4D09-916A-8C6106F5E7C8
// Assembly location: F:\Eigene Dateien\Dropbox\portable Collection\Progs\CarotDAV\CarotDAV.exe
using Microsoft.VisualBasic.CompilerServices ;
using Rei.Com ;
using Rei.Fs ;
using System ;
using System.Collections.Generic ;
using System.Diagnostics ;
using System.IO ;
using System.Runtime.CompilerServices ;
using System.Runtime.InteropServices.ComTypes ;
using System.Text ;
using System.Threading ;
using System.Windows.Forms ;
namespace CarotDAV
{
public class CarotDAVDataObject : Rei . Com . DataObject
{
private ConnectionSettingBase pCs ;
private FsBase pFs ;
private CarotDAVDataObject . CarotDAVDataObjectType pType ;
internal DragDropEffects pReturn ;
private List < VirtualFileInfo > pFileList ;
private List < Uri > pUriList ;
private bool pDirty ;
private ResourceInfo [ ] pResources ;
private CacheManager pCache ;
private bool threadcomp ;
private bool pCanCopyInternally ;
private bool pCanMoveInternally ;
internal int files ;
internal long sizes ;
internal int folders ;
internal int restfolders ;
internal ResourceId targetid ;
internal object syncobject ;
internal Exception ex ;
private CarotDAVDataObject . CarotDAVDataObjectState pState ;
public ErrorPromptManager pErrorManager ;
private EventHandler < ExceptionOccurredEventArgs > pExceptionHandler ;
public bool IsInUsebymyself ;
private bool pDisposed ;
public event CarotDAVDataObject . LogMessageEventHandler LogMessage ;
public event CarotDAVDataObject . ReleaseEventHandler Release ;
public ResourceInfo [ ] Resources
{
get
{
return this . pResources ;
}
}
public CarotDAVDataObject . CarotDAVDataObjectType Type
{
get
{
return this . pType ;
}
}
public bool CanCopyInternally
{
get
{
return this . pCanCopyInternally ;
}
}
public bool CanMoveInternally
{
get
{
return this . pCanMoveInternally ;
}
}
public CarotDAVDataObject . CarotDAVDataObjectState State
{
get
{
return this . pState ;
}
set
{
if ( this . pState = = value )
return ;
if ( this . pState = = CarotDAVDataObject . CarotDAVDataObjectState . Cancelled )
throw new InvalidOperationException ( ) ;
switch ( value )
{
case CarotDAVDataObject . CarotDAVDataObjectState . WaitTransfer :
this . pState = CarotDAVDataObject . CarotDAVDataObjectState . WaitTransfer ;
break ;
case CarotDAVDataObject . CarotDAVDataObjectState . Finished :
case CarotDAVDataObject . CarotDAVDataObjectState . Cancelled :
lock ( this . pFileList )
{
this . pFileList . Clear ( ) ;
this . pUriList . Clear ( ) ;
this . RemoveAll ( ) ;
this . pDirty = false ;
this . pState = value ;
break ;
}
default :
throw new InvalidOperationException ( ) ;
}
}
}
public CarotDAVDataObject ( ConnectionSettingBase cs , ResourceInfo [ ] resources , CarotDAVDataObject . CarotDAVDataObjectType type , CacheManager cache )
{
this . AsyncOperationStart + = new EventHandler ( this . CarotDAVDataObject_AsyncOperationStart ) ;
this . AsyncOperationFinished + = new EventHandler < Rei . Com . DataObject . AsyncOperationFinishedEventArgs > ( this . CarotDAVDataObject_AsyncOperationFinished ) ;
this . DataQueried + = new EventHandler < Rei . Com . DataObject . DataEventArgs > ( this . CarotDAVDataObject_DataQueried ) ;
this . DataRequested + = new EventHandler < Rei . Com . DataObject . DataEventArgs > ( this . CarotDAVDataObject_DataRequested ) ;
this . Release + = new CarotDAVDataObject . ReleaseEventHandler ( this . CarotDAVDataObject_Release ) ;
this . pFileList = new List < VirtualFileInfo > ( ) ;
this . pUriList = new List < Uri > ( ) ;
this . syncobject = RuntimeHelpers . GetObjectValue ( new object ( ) ) ;
this . pErrorManager = new ErrorPromptManager ( ) ;
this . pExceptionHandler = new EventHandler < ExceptionOccurredEventArgs > ( this . OnExceptionOccurred ) ;
this . pDisposed = false ;
this . AsyncSupported = true ;
this . IsInUsebymyself = false ;
this . pCs = cs ;
this . pDirty = true ;
this . pFs = cs . GetClient ( ) ;
this . pFs . GroupName = "OLE" + DateTime . Now . ToString ( ) ;
this . pResources = resources ;
this . pState = CarotDAVDataObject . CarotDAVDataObjectState . WaitListing ;
this . pType = type ;
this . pCache = cache ;
switch ( type )
{
case CarotDAVDataObject . CarotDAVDataObjectType . Cut :
this . SetPreferredDropEffect ( DragDropEffects . Move ) ;
break ;
case CarotDAVDataObject . CarotDAVDataObjectType . Copy :
this . SetPreferredDropEffect ( DragDropEffects . Copy ) ;
break ;
case CarotDAVDataObject . CarotDAVDataObjectType . DragDrop :
this . SetPreferredDropEffect ( DragDropEffects . Copy ) ;
break ;
}
if ( this . pResources . Length = = 1 )
this . SetUri ( this . pResources [ 0 ] . Id . Uri ) ;
string [ ] strs = new string [ checked ( this . pResources . Length - 1 + 1 ) ] ;
int num1 = 0 ;
int num2 = checked ( this . pResources . Length - 1 ) ;
int index1 = num1 ;
while ( index1 < = num2 )
{
strs [ index1 ] = this . pResources [ index1 ] . Id . Uri . ToString ( ) ;
checked { + + index1 ; }
}
this . SetTexts ( strs ) ;
CarotDAVDataObject . InterAppDataStore interAppDataStore = new CarotDAVDataObject . InterAppDataStore ( ) ;
int num3 = 0 ;
int num4 = checked ( resources . Length - 1 ) ;
int index2 = num3 ;
while ( index2 < = num4 )
{
interAppDataStore . Files . Add ( resources [ index2 ] . Id ) ;
checked { + + index2 ; }
}
interAppDataStore . Type = this . pType ;
interAppDataStore . ConnectionSetting = this . pCs ;
interAppDataStore . ID = ( long ) Process . GetCurrentProcess ( ) . Id ;
this . SetManagedObject ( ( object ) interAppDataStore ) ;
this . pCanCopyInternally = true ;
this . pCanMoveInternally = true ;
int num5 = 0 ;
int num6 = checked ( this . pResources . Length - 1 ) ;
int index3 = num5 ;
while ( index3 < = num6 )
{
if ( ! this . pResources [ index3 ] . CanCopy )
this . pCanCopyInternally = false ;
if ( ! this . pResources [ index3 ] . CanMove )
this . pCanMoveInternally = false ;
checked { + + index3 ; }
}
this . pFs . LogMessage + = new EventHandler < LogMessageEventArgs > ( this . pFS_LogMessage ) ;
}
protected override void Dispose ( bool disposing )
{
try
{
if ( ! this . pDisposed )
return ;
int num = disposing ? 1 : 0 ;
}
finally
{
base . Dispose ( disposing ) ;
}
}
public override FORMATETC [ ] SupportedFormats ( )
{
List < FORMATETC > formatetcList = new List < FORMATETC > ( ) ;
formatetcList . AddRange ( ( IEnumerable < FORMATETC > ) base . SupportedFormats ( ) ) ;
2017-10-06 18:20:35 +02:00
FORMATETC formatetc = new FORMATETC ( ) ;
2017-10-06 17:20:58 +02:00
formatetc . dwAspect = DVASPECT . DVASPECT_CONTENT ;
formatetc . lindex = - 1 ;
formatetc . tymed = TYMED . TYMED_HGLOBAL ;
formatetc . cfFormat = Rei . Com . DataObject . MakecfFormat ( ShellClipboardFormats . FileGroupDescriptorW ) ;
formatetcList . Add ( formatetc ) ;
formatetc . cfFormat = Rei . Com . DataObject . MakecfFormat ( ShellClipboardFormats . FileContents ) ;
formatetc . tymed = TYMED . TYMED_ISTREAM ;
formatetcList . Add ( formatetc ) ;
formatetc . cfFormat = Rei . Com . DataObject . MakecfFormat ( ShellClipboardFormats . ShellIDListArray ) ;
formatetc . tymed = TYMED . TYMED_HGLOBAL ;
formatetcList . Add ( formatetc ) ;
formatetc . cfFormat = Rei . Com . DataObject . MakecfFormat ( ShellClipboardFormats . PasteSucceeded ) ;
formatetc . tymed = TYMED . TYMED_HGLOBAL ;
formatetcList . Add ( formatetc ) ;
return formatetcList . ToArray ( ) ;
}
public void Add ( ResourceInfo ri , string name )
{
if ( this . pCs . DownloadFilenameNormalization ! = UCSNormalization . None )
name = name . Normalize ( ( NormalizationForm ) this . pCs . DownloadFilenameNormalization ) ;
VirtualFileInfo virtualFileInfo = new VirtualFileInfo ( ) ;
virtualFileInfo . FileName = name ;
if ( ri . IsCollection )
{
virtualFileInfo . FileAttributes = FileAttributes . Directory ;
virtualFileInfo . Flags = virtualFileInfo . Flags | FDFlags . FD_ATTRIBUTES ;
}
else
{
virtualFileInfo . FileAttributes = FileAttributes . Normal ;
virtualFileInfo . Flags = virtualFileInfo . Flags | FDFlags . FD_ATTRIBUTES ;
}
if ( DateTime . Compare ( ri . CreationTime , DateTime . MinValue ) ! = 0 )
{
virtualFileInfo . CreationTime = ri . CreationTime ;
virtualFileInfo . Flags = virtualFileInfo . Flags | FDFlags . FD_CREATETIME ;
}
if ( DateTime . Compare ( ri . LastAccessTime , DateTime . MinValue ) ! = 0 )
{
virtualFileInfo . LastAccessTime = ri . LastAccessTime ;
virtualFileInfo . Flags = virtualFileInfo . Flags | FDFlags . FD_ACCESSTIME ;
}
if ( DateTime . Compare ( ri . LastModifiedTime , DateTime . MinValue ) ! = 0 )
{
virtualFileInfo . LastWriteTime = ri . LastModifiedTime ;
virtualFileInfo . Flags = virtualFileInfo . Flags | FDFlags . FD_WRITESTIME ;
}
if ( ri . IsCollection )
{
virtualFileInfo . FileSize = 0 UL ;
virtualFileInfo . Flags = virtualFileInfo . Flags | FDFlags . FD_FILESIZE ;
}
else if ( ri . Size > = 0L )
{
virtualFileInfo . FileSize = checked ( ( ulong ) ri . Size ) ;
virtualFileInfo . Flags = virtualFileInfo . Flags | FDFlags . FD_FILESIZE ;
}
if ( ! ri . IsCollection )
{
OleStreamCreator oleStreamCreator = new OleStreamCreator ( ri , name , this . pFs , this . pErrorManager ) ;
oleStreamCreator . ExceptionOccurred + = this . pExceptionHandler ;
virtualFileInfo . IStreamCreator = ( IStreamCreator ) oleStreamCreator ;
}
lock ( this . pFileList )
{
this . pFileList . Add ( virtualFileInfo ) ;
this . pUriList . Add ( ri . Id . Uri ) ;
this . pDirty = true ;
}
}
public void Update ( )
{
lock ( this . pFileList )
{
if ( ! this . pDirty )
return ;
string [ ] strs = new string [ checked ( this . pUriList . Count - 1 + 1 ) ] ;
int num1 = 0 ;
int num2 = checked ( this . pUriList . Count - 1 ) ;
int index = num1 ;
while ( index < = num2 )
{
strs [ index ] = this . pUriList [ index ] . ToString ( ) ;
checked { + + index ; }
}
this . SetVirtualFiles ( this . pFileList . ToArray ( ) , true ) ;
this . SetTexts ( strs ) ;
this . pDirty = false ;
}
}
public void SetDragDropResult ( DragDropEffects r )
{
this . pReturn = r ;
if ( this . IsInOperation )
return ;
this . OnTransferFinish ( ) ;
}
protected override void OnDataRequested ( Rei . Com . DataObject . DataEventArgs e )
{
if ( ( ( int ) e . Format . cfFormat = = ( int ) Rei . Com . DataObject . MakecfFormat ( ShellClipboardFormats . FileGroupDescriptorW ) | | ( int ) e . Format . cfFormat = = ( int ) Rei . Com . DataObject . MakecfFormat ( ShellClipboardFormats . FileGroupDescriptor ) | | ( ( int ) e . Format . cfFormat = = ( int ) Rei . Com . DataObject . MakecfFormat ( DataFormats . UnicodeText ) | | ( int ) e . Format . cfFormat = = ( int ) Rei . Com . DataObject . MakecfFormat ( DataFormats . Text ) ) ) & & this . State = = CarotDAVDataObject . CarotDAVDataObjectState . WaitListing )
{
this . threadcomp = false ;
Thread thread = new Thread ( new ParameterizedThreadStart ( this . ThreadStartPoint ) ) ;
thread . Start ( ( object ) this ) ;
DateTime now = DateTime . Now ;
DialogResult dialogResult = DialogResult . OK ;
while ( ! thread . Join ( 100 ) )
{
if ( DateTime . Now . Subtract ( now ) . TotalSeconds > 1.0 )
{
using ( ResouceListingForm resouceListingForm = new ResouceListingForm ( ) )
{
resouceListingForm . Thread = thread ;
resouceListingForm . pDataObject = this ;
dialogResult = resouceListingForm . ShowDialog ( ) ;
thread . Abort ( ) ;
break ;
}
}
}
thread . Join ( ) ;
if ( this . ex ! = null )
throw this . ex ;
if ( dialogResult ! = DialogResult . OK | | ! this . threadcomp )
{
this . State = CarotDAVDataObject . CarotDAVDataObjectState . Cancelled ;
this . pFs . ResetConnection ( ) ;
}
else
this . State = CarotDAVDataObject . CarotDAVDataObjectState . WaitTransfer ;
}
base . OnDataRequested ( e ) ;
}
private void ThreadStartPoint ( object param )
{
try
{
ErrorPromptManager pDragErrorManager = new ErrorPromptManager ( ) ;
LinkedList < KeyValuePair < ResourceInfo , string > > linkedList1 = new LinkedList < KeyValuePair < ResourceInfo , string > > ( ) ;
Dictionary < ResourceInfo , string > dictionary1 = new Dictionary < ResourceInfo , string > ( ) ;
this . targetid = this . Resources [ 0 ] . Id ;
ResourceInfo [ ] resources = this . Resources ;
List < string > stringList = new List < string > ( ) ;
Dictionary < string , List < int > > dictionary2 = new Dictionary < string , List < int > > ( ) ;
int num1 = 0 ;
int num2 = checked ( resources . Length - 1 ) ;
int index1 = num1 ;
KeyValuePair < ResourceInfo , string > keyValuePair1 ;
while ( index1 < = num2 )
{
if ( resources [ index1 ] . Id . Uri . Segments . Length < = 1 )
{
LinkedList < KeyValuePair < ResourceInfo , string > > linkedList2 = linkedList1 ;
keyValuePair1 = new KeyValuePair < ResourceInfo , string > ( resources [ index1 ] , "root" ) ;
KeyValuePair < ResourceInfo , string > keyValuePair2 = keyValuePair1 ;
linkedList2 . AddFirst ( keyValuePair2 ) ;
Interlocked . Increment ( ref this . folders ) ;
Interlocked . Increment ( ref this . restfolders ) ;
}
else
{
string absolutePath = UriUtil . GetParent ( resources [ index1 ] . Id . Uri ) . AbsolutePath ;
if ( ! dictionary2 . ContainsKey ( absolutePath ) )
{
stringList . Add ( absolutePath ) ;
dictionary2 . Add ( absolutePath , new List < int > ( ) ) ;
}
dictionary2 [ absolutePath ] . Add ( index1 ) ;
}
checked { + + index1 ; }
}
int num3 = 0 ;
int num4 = checked ( stringList . Count - 1 ) ;
int index2 = num3 ;
while ( index2 < = num4 )
{
string index3 = stringList [ index2 ] ;
if ( dictionary2 [ index3 ] . Count < 3 )
{
int num5 = 0 ;
int num6 = checked ( dictionary2 [ index3 ] . Count - 1 ) ;
int index4 = num5 ;
while ( index4 < = num6 )
{
ResourceInfo [ ] info = this . InnerGetInfo ( resources [ dictionary2 [ index3 ] [ index4 ] ] . Id , pDragErrorManager ) ;
if ( info = = null )
return ;
ResourceInfo key = info [ 0 ] ;
string lastName = UriUtil . GetLastName ( key . Id . Uri ) ;
if ( ! key . IsCollection )
{
dictionary1 . Add ( key , lastName ) ;
Interlocked . Increment ( ref this . files ) ;
Interlocked . Add ( ref this . sizes , key . Size ) ;
}
else
{
LinkedList < KeyValuePair < ResourceInfo , string > > linkedList2 = linkedList1 ;
keyValuePair1 = new KeyValuePair < ResourceInfo , string > ( key , lastName ) ;
KeyValuePair < ResourceInfo , string > keyValuePair2 = keyValuePair1 ;
linkedList2 . AddFirst ( keyValuePair2 ) ;
Interlocked . Increment ( ref this . folders ) ;
Interlocked . Increment ( ref this . restfolders ) ;
}
checked { + + index4 ; }
}
}
else
{
ResourceInfo [ ] parentInfoAndEntries = this . InnerGetParentInfoAndEntries ( resources [ dictionary2 [ index3 ] [ 0 ] ] . Id , pDragErrorManager ) ;
if ( parentInfoAndEntries = = null )
return ;
int num5 = 0 ;
int num6 = checked ( dictionary2 [ index3 ] . Count - 1 ) ;
int index4 = num5 ;
while ( index4 < = num6 )
{
int num7 = 1 ;
int num8 = checked ( parentInfoAndEntries . Length - 1 ) ;
int index5 = num7 ;
while ( index5 < = num8 )
{
if ( parentInfoAndEntries [ index5 ] . Id . Uri = = resources [ dictionary2 [ index3 ] [ index4 ] ] . Id . Uri )
{
ResourceInfo key = parentInfoAndEntries [ index5 ] ;
string lastName = UriUtil . GetLastName ( key . Id . Uri ) ;
if ( ! key . IsCollection )
{
dictionary1 . Add ( key , lastName ) ;
Interlocked . Increment ( ref this . files ) ;
Interlocked . Add ( ref this . sizes , key . Size ) ;
}
else
{
LinkedList < KeyValuePair < ResourceInfo , string > > linkedList2 = linkedList1 ;
keyValuePair1 = new KeyValuePair < ResourceInfo , string > ( key , lastName ) ;
KeyValuePair < ResourceInfo , string > keyValuePair2 = keyValuePair1 ;
linkedList2 . AddFirst ( keyValuePair2 ) ;
Interlocked . Increment ( ref this . folders ) ;
Interlocked . Increment ( ref this . restfolders ) ;
}
}
checked { + + index5 ; }
}
checked { + + index4 ; }
}
}
checked { + + index2 ; }
}
while ( linkedList1 . First ! = null )
{
KeyValuePair < ResourceInfo , string > keyValuePair2 = linkedList1 . First . Value ;
linkedList1 . RemoveFirst ( ) ;
ResourceInfo [ ] entries = this . InnerGetEntries ( keyValuePair2 . Key . Id , pDragErrorManager ) ;
dictionary1 . Add ( keyValuePair2 . Key , keyValuePair2 . Value ) ;
int num5 = 0 ;
int num6 = checked ( entries . Length - 1 ) ;
int index3 = num5 ;
while ( index3 < = num6 )
{
string str = Path . Combine ( keyValuePair2 . Value , UriUtil . GetLastName ( entries [ index3 ] . Id . Uri ) ) ;
if ( ! entries [ index3 ] . IsCollection )
{
dictionary1 . Add ( entries [ index3 ] , str ) ;
Interlocked . Increment ( ref this . files ) ;
Interlocked . Add ( ref this . sizes , entries [ index3 ] . Size ) ;
}
else
{
LinkedList < KeyValuePair < ResourceInfo , string > > linkedList2 = linkedList1 ;
keyValuePair1 = new KeyValuePair < ResourceInfo , string > ( entries [ index3 ] , str ) ;
KeyValuePair < ResourceInfo , string > keyValuePair3 = keyValuePair1 ;
linkedList2 . AddFirst ( keyValuePair3 ) ;
Interlocked . Increment ( ref this . folders ) ;
Interlocked . Increment ( ref this . restfolders ) ;
}
checked { + + index3 ; }
}
Interlocked . Decrement ( ref this . restfolders ) ;
}
2017-10-06 18:20:35 +02:00
Dictionary < ResourceInfo , string > . Enumerator enumerator = dictionary1 . GetEnumerator ( ) ;
2017-10-06 17:20:58 +02:00
try
{
while ( enumerator . MoveNext ( ) )
{
KeyValuePair < ResourceInfo , string > current = enumerator . Current ;
this . Add ( current . Key , current . Value ) ;
}
}
finally
{
enumerator . Dispose ( ) ;
}
this . Update ( ) ;
this . threadcomp = true ;
}
catch ( Exception ex )
{
ProjectData . SetProjectError ( ex ) ;
this . ex = ex ;
ProjectData . ClearProjectError ( ) ;
}
finally
{
}
}
private ResourceInfo [ ] InnerGetParentInfoAndEntries ( ResourceId id , ErrorPromptManager pDragErrorManager )
{
this . targetid = id ;
int retryminutes = 1 ;
ResourceInfo [ ] resourceInfoArray ;
while ( true )
{
try
{
return this . pCache . GetParentInfoAndEntries ( this . pFs , id , false ) ;
}
catch ( ThreadAbortException ex )
{
ProjectData . SetProjectError ( ( Exception ) ex ) ;
throw ;
}
catch ( Exception ex1 )
{
ProjectData . SetProjectError ( ex1 ) ;
Exception ex2 = ex1 ;
if ( ex2 . InnerException is ThreadAbortException )
{
throw ;
}
else
{
ErrorAction errorAction ;
if ( pDragErrorManager . IgnoreAll ( ) )
{
errorAction = ErrorAction . Ignore ;
}
else
{
ExceptionOccurredEventArgs e = new ExceptionOccurredEventArgs ( "Error occurred during retrieving properties." , id . ToString ( ) , ErrorPromptType . IgnoreAllIgnoreRetryCancel , ex2 , retryminutes ) ;
this . OnExceptionOccurred ( ( object ) this , e ) ;
pDragErrorManager . RegisterAction ( e . Result ) ;
errorAction = e . Result . Action ;
}
switch ( errorAction )
{
case ErrorAction . Ignore :
resourceInfoArray = new ResourceInfo [ 0 ] ;
ProjectData . ClearProjectError ( ) ;
goto label_15 ;
case ErrorAction . Retry :
ProjectData . ClearProjectError ( ) ;
continue ;
case ErrorAction . AutoRetry :
checked { retryminutes * = 2 ; }
ProjectData . ClearProjectError ( ) ;
continue ;
case ErrorAction . Cancel :
resourceInfoArray = ( ResourceInfo [ ] ) null ;
ProjectData . ClearProjectError ( ) ;
goto label_15 ;
default :
throw ;
}
}
}
}
label_15 :
return resourceInfoArray ;
}
private ResourceInfo [ ] InnerGetInfo ( ResourceId id , ErrorPromptManager pDragErrorManager )
{
this . targetid = id ;
int retryminutes = 1 ;
ResourceInfo info ;
ResourceInfo [ ] resourceInfoArray ;
while ( true )
{
try
{
info = this . pCache . GetInfo ( this . pFs , id , false ) ;
break ;
}
catch ( ThreadAbortException ex )
{
ProjectData . SetProjectError ( ( Exception ) ex ) ;
throw ;
}
catch ( Exception ex1 )
{
ProjectData . SetProjectError ( ex1 ) ;
Exception ex2 = ex1 ;
if ( ex2 . InnerException is ThreadAbortException )
{
throw ;
}
else
{
ErrorAction errorAction ;
if ( pDragErrorManager . IgnoreAll ( ) )
{
errorAction = ErrorAction . Ignore ;
}
else
{
ExceptionOccurredEventArgs e = new ExceptionOccurredEventArgs ( "Error occurred during retrieving properties." , id . ToString ( ) , ErrorPromptType . IgnoreAllIgnoreRetryCancel , ex2 , retryminutes ) ;
this . OnExceptionOccurred ( ( object ) this , e ) ;
pDragErrorManager . RegisterAction ( e . Result ) ;
errorAction = e . Result . Action ;
}
switch ( errorAction )
{
case ErrorAction . Ignore :
resourceInfoArray = new ResourceInfo [ 0 ] ;
ProjectData . ClearProjectError ( ) ;
goto label_16 ;
case ErrorAction . Retry :
ProjectData . ClearProjectError ( ) ;
continue ;
case ErrorAction . AutoRetry :
checked { retryminutes * = 2 ; }
ProjectData . ClearProjectError ( ) ;
continue ;
case ErrorAction . Cancel :
resourceInfoArray = ( ResourceInfo [ ] ) null ;
ProjectData . ClearProjectError ( ) ;
goto label_16 ;
default :
throw ;
}
}
}
}
return new ResourceInfo [ 1 ] { info } ;
label_16 :
return resourceInfoArray ;
}
private ResourceInfo [ ] InnerGetEntries ( ResourceId id , ErrorPromptManager pDragErrorManager )
{
this . targetid = id ;
int retryminutes = 1 ;
ResourceInfo [ ] resourceInfoArray ;
while ( true )
{
try
{
return this . pCache . GetEntries ( this . pFs , id , false ) ;
}
catch ( ThreadAbortException ex )
{
ProjectData . SetProjectError ( ( Exception ) ex ) ;
throw ;
}
catch ( Exception ex1 )
{
ProjectData . SetProjectError ( ex1 ) ;
Exception ex2 = ex1 ;
if ( ex2 . InnerException is ThreadAbortException )
{
throw ;
}
else
{
ErrorAction errorAction ;
if ( pDragErrorManager . IgnoreAll ( ) )
{
errorAction = ErrorAction . Ignore ;
}
else
{
ExceptionOccurredEventArgs e = new ExceptionOccurredEventArgs ( "Error occurred during retrieving properties." , id . ToString ( ) , ErrorPromptType . IgnoreAllIgnoreRetryCancel , ex2 , retryminutes ) ;
this . OnExceptionOccurred ( ( object ) this , e ) ;
pDragErrorManager . RegisterAction ( e . Result ) ;
errorAction = e . Result . Action ;
}
switch ( errorAction )
{
case ErrorAction . Ignore :
Interlocked . Decrement ( ref this . restfolders ) ;
resourceInfoArray = new ResourceInfo [ 0 ] ;
ProjectData . ClearProjectError ( ) ;
goto label_15 ;
case ErrorAction . Retry :
ProjectData . ClearProjectError ( ) ;
continue ;
case ErrorAction . AutoRetry :
checked { retryminutes * = 2 ; }
ProjectData . ClearProjectError ( ) ;
continue ;
case ErrorAction . Cancel :
resourceInfoArray = ( ResourceInfo [ ] ) null ;
ProjectData . ClearProjectError ( ) ;
goto label_15 ;
default :
throw ;
}
}
}
}
label_15 :
return resourceInfoArray ;
}
protected override void OnDataStored ( Rei . Com . DataObject . DataEventArgs e )
{
base . OnDataStored ( e ) ;
if ( ( int ) e . Format . cfFormat ! = ( int ) Rei . Com . DataObject . MakecfFormat ( ShellClipboardFormats . PasteSucceeded ) )
return ;
this . pReturn = this . GetPasteSucceeded ( ) ;
if ( this . IsInOperation )
return ;
this . OnTransferFinish ( ) ;
}
protected virtual void PerformDeleteOnPaste ( )
{
if ( this . GetPerformedDropEffect ( ) ! = DragDropEffects . Move )
return ;
int num1 = 0 ;
int num2 = checked ( this . Resources . Length - 1 ) ;
int index = num1 ;
while ( index < = num2 )
{
int retryminutes = 1 ;
while ( true )
{
ResourceId id = this . Resources [ index ] . Id ;
try
{
this . pCache . Delete ( this . pFs , id ) ;
break ;
}
catch ( Exception ex1 )
{
ProjectData . SetProjectError ( ex1 ) ;
Exception ex2 = ex1 ;
ErrorAction errorAction ;
if ( this . pErrorManager . IgnoreAll ( ) )
{
errorAction = ErrorAction . Ignore ;
}
else
{
ExceptionOccurredEventArgs e = new ExceptionOccurredEventArgs ( "Error occurred during deleting resource." , id . ToString ( ) , ErrorPromptType . IgnoreAllIgnoreRetryCancel , ex2 , retryminutes ) ;
this . OnExceptionOccurred ( ( object ) this , e ) ;
this . pErrorManager . RegisterAction ( e . Result ) ;
errorAction = e . Result . Action ;
}
switch ( errorAction )
{
case ErrorAction . Retry :
ProjectData . ClearProjectError ( ) ;
continue ;
case ErrorAction . AutoRetry :
checked { retryminutes * = 2 ; }
ProjectData . ClearProjectError ( ) ;
continue ;
case ErrorAction . Cancel :
ProjectData . ClearProjectError ( ) ;
return ;
default :
ProjectData . ClearProjectError ( ) ;
goto label_14 ;
}
}
}
label_14 :
checked { + + index ; }
}
}
private void OnExceptionOccurred ( object sender , ExceptionOccurredEventArgs e )
{
e . Result = ErrorPromptForm . ShowDialog ( ( IWin32Window ) null , e . Message , e . Target , e . Exception , e . Type , e . RetryMinutes ) ;
}
private void pFS_LogMessage ( object sender , LogMessageEventArgs e )
{
2017-10-06 18:20:35 +02:00
CarotDAVDataObject . LogMessageEventHandler logMessageEvent = this . LogMessage ;
2017-10-06 17:20:58 +02:00
if ( logMessageEvent = = null )
return ;
logMessageEvent ( RuntimeHelpers . GetObjectValue ( sender ) , e ) ;
}
public void OnTransferFinish ( )
{
this . PerformDeleteOnPaste ( ) ;
this . State = CarotDAVDataObject . CarotDAVDataObjectState . Finished ;
2017-10-06 18:20:35 +02:00
CarotDAVDataObject . ReleaseEventHandler releaseEvent = this . Release ;
2017-10-06 17:20:58 +02:00
if ( releaseEvent = = null )
return ;
releaseEvent ( ( object ) this , EventArgs . Empty ) ;
}
private void CarotDAVDataObject_AsyncOperationStart ( object sender , EventArgs e )
{
}
private void CarotDAVDataObject_AsyncOperationFinished ( object sender , Rei . Com . DataObject . AsyncOperationFinishedEventArgs e )
{
this . OnTransferFinish ( ) ;
}
private void CarotDAVDataObject_DataQueried ( object sender , Rei . Com . DataObject . DataEventArgs e )
{
if ( e . Format . ptd ! = IntPtr . Zero )
return ;
FORMATETC format = e . Format ;
if ( format . dwAspect ! = DVASPECT . DVASPECT_CONTENT )
return ;
format = e . Format ;
if ( format . lindex ! = - 1 )
return ;
format = e . Format ;
if ( ( int ) format . cfFormat = = ( int ) BitConverter . ToInt16 ( BitConverter . GetBytes ( DataFormats . GetFormat ( "FileContents" ) . Id ) , 0 ) & & ( e . Format . tymed & TYMED . TYMED_ISTREAM ) ! = TYMED . TYMED_NULL )
{
e . QueryResult = Rei . Com . DataObject . QueryGetDataResultType . Exists ;
}
else
{
if ( ( int ) e . Format . cfFormat = = ( int ) BitConverter . ToInt16 ( BitConverter . GetBytes ( DataFormats . GetFormat ( "FileGroupDescriptorW" ) . Id ) , 0 ) )
{
format = e . Format ;
if ( ( format . tymed & TYMED . TYMED_HGLOBAL ) ! = TYMED . TYMED_NULL )
{
e . QueryResult = Rei . Com . DataObject . QueryGetDataResultType . Exists ;
return ;
}
}
if ( ( int ) e . Format . cfFormat ! = ( int ) BitConverter . ToInt16 ( BitConverter . GetBytes ( DataFormats . GetFormat ( "FileGroupDescriptor" ) . Id ) , 0 ) )
return ;
format = e . Format ;
if ( ( format . tymed & TYMED . TYMED_HGLOBAL ) = = TYMED . TYMED_NULL )
return ;
e . QueryResult = Rei . Com . DataObject . QueryGetDataResultType . Exists ;
}
}
private void CarotDAVDataObject_DataRequested ( object sender , Rei . Com . DataObject . DataEventArgs e )
{
}
private void CarotDAVDataObject_Release ( object sender , EventArgs e )
{
}
public enum CarotDAVDataObjectState
{
WaitListing ,
WaitTransfer ,
Finished ,
Cancelled ,
}
public enum CarotDAVDataObjectType
{
Cut ,
Copy ,
DragDrop ,
}
public delegate void LogMessageEventHandler ( object sender , LogMessageEventArgs e ) ;
public delegate void ReleaseEventHandler ( object sender , EventArgs e ) ;
[Serializable]
public class InterAppDataStore
{
public List < ResourceId > Files ;
public CarotDAVDataObject . CarotDAVDataObjectType Type ;
public ConnectionSettingBase ConnectionSetting ;
public long ID ;
public InterAppDataStore ( )
{
this . Files = new List < ResourceId > ( ) ;
}
}
}
}