/* * This file was generated by the SOM Compiler. * FileName: BlackHol.c. * Generated using: * SOM Precompiler spc: 1.22 * SOM Emitter emitc: 1.24 */ /*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ Greg's Black Hole - anything you put in will disappear forever... ³ ³ This version resolves folder structure ³ ³ and reset Read only attribute... Dangerous ! ³ ³ Gregory Czaja, 71052,720 November 1992 ³ ³ will allow removing desktop, if not the current one December 1992 ³ ³ better class checking for dropped objects January 1993 ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ #define BlackHole_Class_Source #include "BlackHol.ih" #include #include #include #include #include #include #include void ResolveAndDelete(WPObject * pWPObject); SOM_Scope MRESULT SOMLINK BlackHolX_wpDragOver(BlackHole *somSelf, HWND hwndCnr, PDRAGINFO pdrgInfo) { ULONG ulItemCnt=0; ULONG ulItem=0; USHORT usDropIndic=DOR_DROP; BlackHoleData *somThis = BlackHoleGetData(somSelf); BlackHoleMethodDebug("BlackHole","BlackHolX_wpDragOver"); /* Check that items are workplace shell objects */ ulItemCnt=DrgQueryDragitemCount(pdrgInfo); for(ulItem=0;ulItemulItemID); object =_wpQueryTitle(pWPObjDropped); pszClass =(PSZ)_somGetClassName(pWPObjDropped); sprintf(message, "You are about to delete: %s including the entire contents, if any.\ \nPush \"Yes\" to confirm, \"No\" to cancel!", object); if (MBID_YES == WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, message, "Black Hole - destroy object", 0, MB_YESNO | MB_DEFBUTTON2 | MB_WARNING | MB_SYSTEMMODAL )){ /* wants a VERY special delete ??? */ if (strcmp(pszClass, "WPDesktop") == 0) { /* is this the current desktop ? */ if (_wpIsCurrentDesktop(pWPObjDropped)) { WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, "You must be joking... \ Do you realy want to delete your Desktop ?", "DeskMan/2 - destroy object", 0, MB_CANCEL | MB_WARNING | MB_SYSTEMMODAL ); } else { if (MBID_YES == WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, "Deleting an inactive Desktop may cause problems on some systems.\ Objects on the active Desktop may be damaged.\ \nDo you want to continue ?", "Black Hole - Destroy object", 0, MB_YESNO | MB_DEFBUTTON2 | MB_WARNING | MB_SYSTEMMODAL )){ ResolveAndDelete(pWPObjDropped); }; } /* endif */ } else { ResolveAndDelete(pWPObjDropped); } /* endif */ }; free(message); return (parent_wpDrop(somSelf,hwndCnr,pdrgInfo,pdrgItem)); } #undef SOM_CurrentClass #define SOM_CurrentClass SOMMeta SOM_Scope void SOMLINK BlackHolC_wpclsInitData(M_BlackHole *somSelf) { /* M_BlackHoleData *somThis = M_BlackHoleGetData(somSelf); */ M_BlackHoleMethodDebug("M_BlackHole","BlackHolC_wpclsInitData"); parent_wpclsInitData(somSelf); } SOM_Scope void SOMLINK BlackHolC_wpclsUnInitData(M_BlackHole *somSelf) { /* M_BlackHoleData *somThis = M_BlackHoleGetData(somSelf); */ M_BlackHoleMethodDebug("M_BlackHole","BlackHolC_wpclsUnInitData"); parent_wpclsUnInitData(somSelf); } /*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ORDINARY CODE SECTION ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³**** ****³ ³**** Any non-method code should go here. ****³ ³**** ****³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ #undef SOM_CurrentClass /*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ ResolveAndDelete ³ ³ Purpose: resolves composite objects and deletes atomic ones... ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ VOID ResolveAndDelete(WPObject * pWPObject) { ULONG ulFlags; PSZ message =malloc(256); PSZ pszObject =_wpQueryTitle(pWPObject); PSZ pszClass =(PSZ)_somGetClassName(pWPObject); SOMClass *Class=_somClassFromId(SOMClassMgrObject, SOM_IdFromString(pszClass)); SOMClass *FolderClass=_somClassFromId(SOMClassMgrObject, SOM_IdFromString("WPFolder")); SOMClass *FileSystemClass=_somClassFromId(SOMClassMgrObject, SOM_IdFromString("WPFileSystem")); /* those are represented by real files... */ if (_somDescendedFrom(Class, FileSystemClass)){ /* get the object's file Attributes... */ ulFlags=_wpQueryAttr(pWPObject); /* now reset the read only bit */ _wpSetAttr(pWPObject, ulFlags & ~FILE_READONLY); } /* endif */ /* resolve composite objects if necessary */ if (_somDescendedFrom(Class, FolderClass)){ PSZ pszFilename=NULL; ULONG pcb; /* get the real name for populate */ if _wpQueryRealName(pWPObject,NULL,&pcb,TRUE){ pszFilename=malloc(pcb+2); /* get the buffer */ memset(pszFilename,'\0',pcb+1); _wpQueryRealName(pWPObject,pszFilename,&pcb,TRUE); } /* endif */ if (_wpPopulate(pWPObject, 0L, pszFilename, FALSE)) { WPObject * pWPObjectTemp; /* go through folder's content */ for(pWPObjectTemp=_wpQueryContent(pWPObject,pWPObjectTemp,QC_First); pWPObjectTemp != NULL; pWPObjectTemp=_wpQueryContent(pWPObject,pWPObjectTemp,QC_Next)) { ResolveAndDelete(pWPObjectTemp); }/* end for */ } /* endif */ if (pszFilename != NULL) free(pszFilename); } /* endif */ /* now reset the noDelete style */ _wpSetStyle(pWPObject, !OBJSTYLE_NODELETE); /* and do the job... */ if ( !_wpFree(pWPObject)) { sprintf(message, "Object: %s could not be deleted !", pszObject); WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, message, "Black Hole - destroy object", 0, MB_CANCEL | MB_WARNING | MB_SYSTEMMODAL ); }; free(message); return; }