void FillList( PSI_CONTROL list,PMACRO_BUTTON button ) { if( list ) { PMACRO_ELEMENT pme = button->elements; ResetList( list ); while( pme ) { SetItemData( AddListItem( list, (pme->button->text&&pme->button->text[0])?pme->button->text:pme->button->pTypeName ), (uintptr_t)pme ); //SetItemText( pli, (pme->button->text&&pme->button->text[0])?pme->button->text:pme->button->pTypeName ); pme = NextThing( pme ); } } }
static void OnShowControl( MACRO_BUTTON_NAME )( uintptr_t psv ) { struct current_macro_state_during_invoke current_invoke_state; current_invoke_state.macro = (PMACRO_BUTTON)psv; if( current_invoke_state.macro ) for( current_invoke_state.element = current_invoke_state.macro->elements; current_invoke_state.element; current_invoke_state.element = NextThing( current_invoke_state.element ) ) { InvokeShowControl( current_invoke_state.element->button ); } current_invoke_state.element = NULL; current_invoke_state.macro = NULL; }
void WriteMacroButton( CTEXTSTR leader, FILE *file, uintptr_t psv ) { PMACRO_BUTTON button = (PMACRO_BUTTON)psv; // save buttons... { PMACRO_ELEMENT element; for( element = button->elements; element; element = NextThing( element ) ) { sack_fprintf( file, WIDE( "%s%sMacro Element \'%s\'\n" ), InterShell_GetSaveIndent(), leader?leader:WIDE( "" ), element->button->pTypeName ); DumpGeneric( file, element->button ); /* begins another sub configuration... */ sack_fprintf( file, WIDE( "%s%smacro element done\n" ), InterShell_GetSaveIndent(), leader?leader:WIDE( "" ) ); //sack_fprintf( file, WIDE( "%sMacro Element Text \'%s\'\n" ), leader?leader:WIDE( "" ), element->button->text ); } sack_fprintf( file, WIDE( "%s%smacro element list done\n" ), InterShell_GetSaveIndent(), leader?leader:WIDE( "" ) ); } }
static void ConfigureMacroButton( PMACRO_BUTTON button, PSI_CONTROL parent ) { PSI_CONTROL frame = LoadXMLFrameOver( parent, WIDE( "ConfigureMacroButton.isFrame" ) ); if( frame ) { int okay = 0; int done = 0; l.configuration_parent = parent; SetCommonButtons( frame, &done, &okay ); { PSI_CONTROL list; SetListboxIsTree( list = GetControl( frame, LIST_CONTROL_TYPES ), 1 ); ResetList( list ); FillControlsList( list, 1, TASK_PREFIX WIDE( "/control" ), NULL ); SetCommonButtonControls( frame ); SetButtonPushMethod( GetControl( frame, BUTTON_ADD_CONTROL ), AddButtonType, (uintptr_t)button ); //SetButtonPushMethod( GetControl( frame, BUTTON_EDIT_CONTROL ), AddButtonType, (uintptr_t)button ); { PSI_CONTROL list = GetControl( frame, LIST_MACRO_ELEMENTS ); if( list ) { PMACRO_ELEMENT pme = button->elements; while( pme ) { SetItemData( AddListItem( list, (pme->button->text&&pme->button->text[0])?pme->button->text:pme->button->pTypeName ), (uintptr_t)pme ); pme = NextThing( pme ); } } } SetButtonPushMethod( GetControl( frame, BUTTON_ELEMENT_UP ), MoveElementUp, (uintptr_t)button ); SetButtonPushMethod( GetControl( frame, BUTTON_ELEMENT_CLONE ), MoveElementClone, (uintptr_t)button ); SetButtonPushMethod( GetControl( frame, BUTTON_ELEMENT_CLONE_ELEMENT ), CloneElement, (uintptr_t)button ); SetButtonPushMethod( GetControl( frame, BUTTON_ELEMENT_DOWN ), MoveElementDown, (uintptr_t)button ); SetButtonPushMethod( GetControl( frame, BUTTON_ELEMENT_CONFIGURE ), ConfigureElement, (uintptr_t)button ); SetButtonPushMethod( GetControl( frame, BUTTON_ELEMENT_REMOVE ), MoveElementRemove, (uintptr_t)button ); } DisplayFrameOver( frame, parent ); CommonWait( frame ); if( okay ) { GetCommonButtonControls( frame ); } DestroyFrame( &frame ); } }
static void CPROC MoveElementDown( uintptr_t psv, PSI_CONTROL control ) { PMACRO_BUTTON button = (PMACRO_BUTTON)psv; PSI_CONTROL list = GetNearControl( control, LIST_MACRO_ELEMENTS ); PLISTITEM pli = GetSelectedItem( list ); PMACRO_ELEMENT pme = (PMACRO_ELEMENT)GetItemData( pli ); if( pme ) { PMACRO_ELEMENT _next = NextThing( pme ); if( (uintptr_t)&pme->next != (uintptr_t)pme ) { lprintf( WIDE( "Failure, structure definition does not have DeclareLink() as first member." ) ); DebugBreak(); } if( _next && pme ) { UnlinkThing( pme ); LinkThingAfter( _next, pme ); FillList( list, button ); } } }
static void InvokeMacroButton( PMACRO_BUTTON button, LOGICAL bBannerMessage ) { struct current_macro_state_during_invoke new_current_macro; if( !pls_macros ) pls_macros = CreateLinkStack(); PushLink( &pls_macros, &new_current_macro ); new_current_macro.macro = button; for( new_current_macro.element = button->elements; new_current_macro.element; new_current_macro.element = NextThing( new_current_macro.element ) ) { if( !QueryShowControl( new_current_macro.element->button ) ) continue; if( new_current_macro.element->button->original_keypress ) { // there really should be some sort of way to abort, and unpress these buttons... // that would be cool, but I don't think that will happen. new_current_macro.element->flags.allow_continue = 1; if( bBannerMessage ) { TEXTCHAR msg[256]; TEXTCHAR msg2[256]; int cur = 0; int ofs; InterShell_TranslateLabelText( NULL, msg2, sizeof( msg2 ), new_current_macro.element->button->text ); for( ofs = 0; msg2[ofs]; ofs++ ) { if( msg2[ofs] == '\\' ) { if( msg2[ofs+1] == 'n' ) { msg2[cur++] = '\n'; ofs++; } } else msg2[cur++] = msg2[ofs]; } msg2[cur++] = msg2[ofs]; snprintf( msg, sizeof( msg ), WIDE("Invoke Startup\n%s"), msg2 ); // friggin visual studio... the spec claims 'will have a nul in buffer' msg[255] = 0; Banner2NoWaitAlpha( msg ); } new_current_macro.element->button->original_keypress( new_current_macro.element->button->psvUser ); if( !new_current_macro.element->flags.allow_continue ) { // abort the page change too. if( new_current_macro.macro->button ) new_current_macro.macro->button->flags.bIgnorePageChange = 1; break; // stop this macro button. } } if( new_current_macro.element->button->pPageName ) { if( !new_current_macro.element->button->canvas ) // probably part of starup or shutdown macro { if( !new_current_macro.element->button->flags.bIgnorePageChange ) { ShellSetCurrentPage( InterShell_GetCanvas( new_current_macro.macro->button->page ) , new_current_macro.element->button->pPageName ); } } else if( new_current_macro.element->button->canvas && !new_current_macro.element->button->flags.bIgnorePageChange ) { //lprintf( WIDE( "Changing pages, but only virtually don't activate the page always" ) ); ShellSetCurrentPage( new_current_macro.element->button->canvas->pc_canvas, new_current_macro.element->button->pPageName ); } new_current_macro.element->button->flags.bIgnorePageChange = 0; } } PopLink( &pls_macros ); }
int ScanFilesEx ( CTEXTSTR base , CTEXTSTR mask , void **pInfo , void CPROC Process( uintptr_t psvUser, CTEXTSTR name, int flags ) , int flags , uintptr_t psvUser , LOGICAL begin_sub_path , struct file_system_mounted_interface *mount ) { PMFD pDataCurrent = (PMFD)(pInfo); PMFD pData = (PMFD)(*pInfo); TEXTSTR tmp_base = NULL; int sendflags; int processed = 0; #ifndef WIN32 struct dirent *de; #endif if( begin_sub_path ) { pInfo = (void**)&(pDataCurrent->current); } else pDataCurrent = NULL; //lprintf( "Search in %s for %s %d %d", base?base:"(NULL)", mask?mask:"(*)", (*pInfo)?((PMFD)*pInfo)->scanning_mount:0, (*pInfo)?((PMFD)*pInfo)->single_mount:0 ); if( !*pInfo || begin_sub_path || ((PMFD)*pInfo)->new_mount ) { TEXTCHAR findmask[256]; pData = (PMFD)(*pInfo); if( !pData ) { *pInfo = Allocate( sizeof( MFD ) ); pData = (PMFD)(*pInfo); if( !( pData->scanning_mount = mount ) ) { if( !winfile_local ) SimpleRegisterAndCreateGlobal( winfile_local ); //lprintf( "... %p", winfile_local ); pData->single_mount = FALSE; pData->scanning_mount = (*winfile_local).mounted_file_systems; } else pData->single_mount = TRUE; if( !pData->scanning_mount ) { Deallocate( PMFD, pData ); if( tmp_base ) Release( tmp_base ); return 0; } if( pData->scanning_mount->fsi ) { //lprintf( "create cursor" ); tmp_base = ExpandPathEx( base, pData->scanning_mount->fsi ); pData->cursor = pData->scanning_mount->fsi->find_create_cursor( pData->scanning_mount->psvInstance, CStrDup( tmp_base ), CStrDup( mask ) ); } else { //lprintf( "no cursor" ); pData->cursor = NULL; } } else { if( pData->new_mount ) { if( pData->scanning_mount->fsi ) { //lprintf( "create cursor (new mount)" ); tmp_base = ExpandPathEx( base, pData->scanning_mount->fsi ); pData->cursor = pData->scanning_mount->fsi->find_create_cursor( pData->scanning_mount->psvInstance, CStrDup( tmp_base ), CStrDup( mask ) ); } else pData->cursor = NULL; } } pData->new_mount = FALSE; pData->current = NULL; pData->prior = pDataCurrent; if( pDataCurrent ) { pData->root_info = pDataCurrent->root_info; pInfo = (void**)pData->root_info; } else { pData->root_info = (struct myfinddata**)pInfo; } (*pData->root_info) = pData; if( base ) { TEXTSTR tmp; StrCpyEx( findbasename(pInfo), tmp = ExpandPathEx( base, pData->scanning_mount?pData->scanning_mount->fsi:NULL ), MAX_PATH_NAME ); Release( tmp ); StrCpyEx( findmask(pInfo), mask, MAX_PATH_NAME ); } else { CTEXTSTR p = pathrchr( mask ); if( p ) { StrCpyEx( findbasename(pInfo), mask, p - mask + 1 ); StrCpyEx( findmask(pInfo), p + 1, MAX_PATH_NAME ); //mask = p + 1; } else { StrCpyEx( findbasename(pInfo), WIDE(""), 2 ); StrCpyEx( findmask(pInfo), mask, MAX_PATH_NAME ); } } if( findbasename(pInfo)[0] ) tnprintf( findmask, sizeof(findmask), WIDE("%s/*"), findbasename(pInfo) ); else tnprintf( findmask, sizeof( findmask ), WIDE( "*" ) ); if( pData->scanning_mount?pData->scanning_mount->fsi:NULL ) if( pData->scanning_mount->fsi->find_first( findcursor(pInfo) ) ) findhandle(pInfo) = 0; else findhandle(pInfo) = (HANDLECAST)-1; else { #if WIN32 findhandle(pInfo) = findfirst( findmask, finddata(pInfo) ); #else //lprintf( "opendir %s", findbasename(pInfo) ); findhandle( pInfo ) = opendir( findbasename(pInfo) ); if( !findhandle(pInfo ) ) findhandle(pInfo) = (HANDLECAST)-1; else de = readdir( (DIR*)findhandle( pInfo ) ); #endif } if( findhandle(pInfo) == (HANDLECAST)-1 ) { PMFD prior = pData->prior; //lprintf( "first use of cursor or first open of directoy failed..." ); if( pData->scanning_mount && pData->scanning_mount->fsi ) pData->scanning_mount->fsi->find_close( (struct find_cursor*)findcursor(pInfo) ); else { #ifdef WIN32 findclose( findhandle(pInfo) ); #else // but it failed... so ... don't close //closedir( findhandle( pInfo ) ); #endif } pData->scanning_mount = NextThing( pData->scanning_mount ); if( !pData->scanning_mount || pData->single_mount ) { (*pData->root_info) = pData->prior; if( !begin_sub_path ) { Release( pData ); pInfo[0] = NULL; } //lprintf( WIDE( "%p %d" ), prior, processed ); if( tmp_base ) Release( tmp_base ); return prior?processed:0; } pData->new_mount = TRUE; if( tmp_base ) Release( tmp_base ); return 1; } } else { int r; getnext: //lprintf( "returning customer..." ); if( pData->scanning_mount?pData->scanning_mount->fsi:NULL ) r = !pData->scanning_mount->fsi->find_next( findcursor( pInfo ) ); else { #ifdef _WIN32 r = findnext( findhandle(pInfo), finddata( pInfo ) ); #else de = readdir( (DIR*)findhandle( pInfo ) ); //lprintf( "using %p got %p", findhandle( pInfo ), de ); r = (de == NULL); #endif } if( r ) { PMFD prior = pData->prior; //lprintf( "nothing left to find..." ); if( pData->scanning_mount->fsi ) pData->scanning_mount->fsi->find_close( findcursor(pInfo) ); else { #ifdef WIN32 findclose( findhandle(pInfo) ); #else closedir( (DIR*)findhandle(pInfo)); #endif } pData->scanning_mount = NextThing( pData->scanning_mount ); //lprintf( "Step mount... %p %d", pData->scanning_mount, pData->single_mount ); if( !pData->scanning_mount || pData->single_mount ) { //lprintf( "done with mounts?" ); (*pData->root_info) = pData->prior; Release( pData ); if( prior ) prior->current = NULL; if( !processed && !begin_sub_path ) { //pInfo = (void**)&(prior->prior->current); pData = prior; if( pData ) goto getnext; } if( tmp_base ) Release( tmp_base ); return (*pInfo)?processed:0; } pData->new_mount = TRUE; if( tmp_base ) Release( tmp_base ); return 1; } } if( pData->scanning_mount?pData->scanning_mount->fsi:NULL ) { char * path = pData->scanning_mount->fsi->find_get_name( findcursor(pInfo) ); //lprintf( "... %s", path ); if( !strcmp( ".", path ) || !strcmp( "..", path ) ) goto getnext; } else { #if WIN32 //lprintf( "... %s", finddata(pInfo)->name ); # ifdef UNDER_CE if( !StrCmp( WIDE("."), finddata(pInfo)->cFileName ) || !StrCmp( WIDE(".."), finddata(pInfo)->cFileName ) ) # else if( !StrCmp( WIDE("."), finddata(pInfo)->name ) || !StrCmp( WIDE(".."), finddata(pInfo)->name ) ) # endif #else if( !StrCmp( WIDE("."), de->d_name ) || !StrCmp( WIDE(".."), de->d_name ) ) #endif goto getnext; } if( !(flags & SFF_NAMEONLY) ) // if nameonly - have to rebuild the correct name. { if( pData->scanning_mount?pData->scanning_mount->fsi:NULL ) { tnprintf( pData->file_buffer, MAX_PATH_NAME, WIDE("%s"), pData->scanning_mount->fsi->find_get_name( findcursor(pInfo) ) ); if( findbasename( pInfo )[0] ) tnprintf( pData->buffer, MAX_PATH_NAME, WIDE("%s/%s"), findbasename(pInfo), pData->file_buffer ); else tnprintf( pData->buffer, MAX_PATH_NAME, WIDE( "%s" ), pData->file_buffer ); } else { #ifdef WIN32 # ifdef UNDER_CE tnprintf( pData->file_buffer, MAX_PATH_NAME, WIDE( "%s" ), finddata( pInfo )->cFileName ); tnprintf( pData->buffer, MAX_PATH_NAME, WIDE("%s/%s"), findbasename(pInfo), finddata(pInfo)->cFileName ); # else tnprintf( pData->file_buffer, MAX_PATH_NAME, WIDE("%s"), finddata(pInfo)->name ); tnprintf( pData->buffer, MAX_PATH_NAME, WIDE("%s%s%s"), findbasename(pInfo), findbasename( pInfo )[0]?"/":"", pData->file_buffer ); # endif #else tnprintf( pData->file_buffer, MAX_PATH_NAME, WIDE("%s"), de->d_name ); tnprintf( pData->buffer, MAX_PATH_NAME, WIDE("%s/%s"), findbasename(pInfo), de->d_name ); #endif } } else { if( flags & SFF_SUBCURSE ) { if( pData->scanning_mount?pData->scanning_mount->fsi:NULL ) { tnprintf( pData->buffer, MAX_PATH_NAME, WIDE("%s%s%s") , pData->prior?pData->prior->buffer:WIDE( "" ) , pData->prior?WIDE( "/" ):WIDE( "" ) , pData->scanning_mount->fsi->find_get_name( findcursor(pInfo) ) ); } else { #if WIN32 # ifdef UNDER_CE tnprintf( pData->buffer, MAX_PATH_NAME, WIDE("%s%s%s") , pData->prior?pData->prior->buffer:WIDE( "" ) , pData->prior?WIDE( "/" ):WIDE( "" ) , finddata(pInfo)->cFileName ); # else tnprintf( pData->buffer, MAX_PATH_NAME, WIDE("%s%s%s") , pData->prior?pData->prior->buffer:WIDE( "" ) , pData->prior?WIDE( "/" ):WIDE( "" ) , finddata(pInfo)->name ); # endif #else tnprintf( pData->buffer, MAX_PATH_NAME, WIDE("%s%s%s") , pData->prior?pData->prior->buffer:WIDE( "" ) , pData->prior?WIDE( "/" ):WIDE( "" ) , de->d_name ); lprintf( "resulting is %s", pData->buffer ); #endif } } else { if( pData->scanning_mount?pData->scanning_mount->fsi:NULL ) { tnprintf( pData->buffer, MAX_PATH_NAME, WIDE("%s"), pData->scanning_mount->fsi->find_get_name( findcursor(pInfo) ) ); } else { #if WIN32 # ifdef UNDER_CE tnprintf( pData->buffer, MAX_PATH_NAME, WIDE("%s"), finddata(pInfo)->cFileName ); # else # ifdef UNICODE snwprintf( pData->buffer, MAX_PATH_NAME, WIDE("%s"), finddata(pInfo)->name ); # else tnprintf( pData->buffer, MAX_PATH_NAME, WIDE("%s"), finddata(pInfo)->name ); # endif # endif #else tnprintf( pData->buffer, MAX_PATH_NAME, WIDE("%s"), de->d_name ); #endif } } } pData->buffer[MAX_PATH_NAME-1] = 0; // force nul termination... #ifdef UNICODE { char *pDataBuffer = CStrDup( pData->buffer ); #else # define pDataBuffer pData->buffer #endif //lprintf( "Check if %s is a directory...", pData->buffer ); if( (flags & (SFF_DIRECTORIES | SFF_SUBCURSE)) && (pData->scanning_mount && pData->scanning_mount->fsi && (pData->scanning_mount->fsi->is_directory && pData->scanning_mount->fsi->is_directory( pDataBuffer ))) || (!(pData->scanning_mount ? pData->scanning_mount->fsi : NULL) #ifdef WIN32 # ifdef UNDER_CE && (finddata( pInfo )->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) # else && (finddata( pInfo )->attrib & _A_SUBDIR) # endif #else && IsPath( pData->buffer ) #endif ) ) { #ifdef UNICODE Deallocate( char *, pDataBuffer ); #else # undef pDataBuffer #endif //lprintf( "... it is?" ); if( flags & SFF_DIRECTORIES ) { if( Process != NULL ) { //lprintf( "Send %s", pData->buffer ); Process( psvUser, pData->buffer, SFF_DIRECTORY ); processed = 1; } //return 1; } if( flags & SFF_SUBCURSE ) { void *data = NULL; int ofs = 0; TEXTCHAR tmpbuf[MAX_PATH_NAME]; if( flags & SFF_NAMEONLY ) { // even in name only - need to have this full buffer for subcurse. if( pData->scanning_mount && pData->scanning_mount->fsi ) { ofs = tnprintf( tmpbuf, sizeof( tmpbuf ), WIDE( "%s/%s" ), findbasename( pInfo ), pData->scanning_mount->fsi->find_get_name( findcursor( pInfo ) ) ); } else { #ifdef WIN32 # ifdef UNDER_CE ofs = tnprintf( tmpbuf, sizeof( tmpbuf ), WIDE( "%s/%s" ), findbasename( pInfo ), finddata( pInfo )->cFileName ); # else # ifdef UNICODE ofs = snwprintf( tmpbuf, sizeof( tmpbuf ), WIDE( "%s/%s" ), findbasename( pInfo ), finddata( pInfo )->name ); # else ofs = tnprintf( tmpbuf, sizeof( tmpbuf ), WIDE( "%s/%s" ), findbasename( pInfo ), finddata( pInfo )->name ); # endif # endif #else ofs = tnprintf( tmpbuf, sizeof( tmpbuf ), WIDE( "%s/%s" ), findbasename( pInfo ), de->d_name ); #endif } //lprintf( "process sub... %s %s", tmpbuf, findmask(pInfo) ); processed |= ScanFilesEx( tmpbuf, findmask( pInfo ), (POINTER*)pData, Process, flags, psvUser, TRUE, pData->scanning_mount ); } else { //lprintf( "process sub..." ); processed |= ScanFilesEx( pData->buffer, findmask( pInfo ), (POINTER*)pData, Process, flags, psvUser, TRUE, pData->scanning_mount ); } } if( !processed ) goto getnext; if( tmp_base ) Release( tmp_base ); return (*pInfo) ? 1 : 0; } #ifdef UNICODE Deallocate( char *, pDataBuffer ); } #else # undef pDataBuffer #endif if( ( sendflags = SFF_DIRECTORY, ( ( flags & SFF_DIRECTORIES ) #ifdef WIN32 # ifdef UNDER_CE && ( finddata(pInfo)->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) # else && ( finddata(pInfo)->attrib & _A_SUBDIR ) # endif #else && ( IsPath( pData->buffer ) ) #endif ) ) || ( sendflags = 0, CompareMask( findmask( pInfo ) #ifdef WIN32 # ifdef UNDER_CE , finddata(pInfo)->cFileName # else , pData->file_buffer # endif #else , de->d_name #endif // yes this is silly - but it's correct... , (flags & SFF_IGNORECASE)?0:0 ) ) ) { //lprintf( "Send %s", pData->buffer ); if( Process != NULL ) Process( psvUser, pData->buffer, sendflags ); if( tmp_base ) Release( tmp_base ); return (*pInfo)?1:0; } if( tmp_base ) Release( tmp_base ); return (*pInfo)?1:0; }