Example #1
0
static PyObject *AEDesc_AEGetAttributeDesc(AEDescObject *_self, PyObject *_args)
{
	PyObject *_res = NULL;
	OSErr _err;
	AEKeyword theAEKeyword;
	DescType desiredType;
	AEDesc result;

	if (!PyArg_ParseTuple(_args, "O&O&",
	                      AE_GetOSType, &theAEKeyword,
	                      AE_GetOSType, &desiredType))
		return NULL;
	_err = AEGetAttributeDesc(&_self->ob_itself,
	                          theAEKeyword,
	                          desiredType,
	                          &result);
	if (_err != noErr) return AE_MacOSError(_err);
	_res = Py_BuildValue("O&",
	                     AE_AEDesc_New, &result);
	return _res;
}
void AddRecordedEvents(PRECORDER_PARM prec, OSAEvent *ptheEvent)
{

   HWND  hwndMle = WinWindowFromID(prec->hwnd, IDD_ODDISPLAYEVENTS);
   PCHAR  pszMleBuf = NULL;
   IPT   lOffset = 0;
   ULONG cbCopied;
   ULONG ulAction;
   ULONG cbLength;
   ULONG bufSize = 1024;
   ULONG dataSize = 0;
   AEDesc result;
   PID   pid;
   Size  size;
   CHAR  szAppName[CCHMAXPATH];
   ULONG cbAppName = CCHMAXPATH;
   ULONG eventClass;
   ULONG eventID;
   PSZ  pszTemp;
   DescType dtype;
   OSErr err;

   pszMleBuf = (PCHAR) calloc(1,bufSize);

   /* Zero-fill the buffer using memset, a C run-time function */
   memset(pszMleBuf, 0, bufSize);

   /* Set the MLE import-export buffer */
   WinSendMsg(hwndMle,
              MLM_SETIMPORTEXPORT,
              MPFROMP(pszMleBuf),
              MPFROMSHORT((USHORT) bufSize));

   /* Find out how much text is in the MLE */
   cbLength = (ULONG) WinSendMsg(hwndMle,
                                MLM_QUERYFORMATTEXTLENGTH,
                                MPFROMLONG(lOffset),
                                MPFROMLONG((-1)));

   lOffset = cbLength + 1; /* insert text at end */

   /* format event into buffer */
   //Get the applications PID
   err = AEGetAttributeDesc(ptheEvent,keyAddressAttr,typeWildCard,&result);
   size = sizeof(PID);
   err = AEGetDescData(&result, &dtype, (Ptr) &pid, (Size) sizeof(PID), &size);
   AEDisposeDesc(&result);
   err = AEGetAppName(pid, szAppName, &cbAppName);

   //Get Event class
   err = AEGetAttributeDesc(ptheEvent,keyEventClassAttr,typeWildCard,&result);
   size = sizeof(ULONG);
   err = AEGetDescData(&result, &dtype, (Ptr) &eventClass, (Size) sizeof(ULONG), &size);
   AEDisposeDesc(&result);
   //Get Event id
   err = AEGetAttributeDesc(ptheEvent,keyEventIDAttr,typeWildCard,&result);
   size = sizeof(ULONG);
   err = AEGetDescData(&result, &dtype, (Ptr) &eventID, (Size) sizeof(ULONG), &size);
   AEDisposeDesc(&result);

   strcpy(pszMleBuf,"******************************\n");
   strcat(pszMleBuf,"\n");
   strcat(pszMleBuf, "Application: ");
   strcat(pszMleBuf,szAppName);
   strcat(pszMleBuf,"\n");
   strcat(pszMleBuf,"Event Class: ");
   pszTemp = pszMleBuf+strlen(pszMleBuf);
   memcpy(pszTemp,&eventClass,sizeof(ULONG));
   pszTemp+=sizeof(ULONG);
   pszTemp = NULL;
   strcat(pszMleBuf,"\n");
   strcat(pszMleBuf,"Event ID: ");
   pszTemp = pszMleBuf+strlen(pszMleBuf);
   memcpy(pszTemp,&eventID,sizeof(ULONG));
   pszTemp+=sizeof(ULONG);
   pszTemp = NULL;
   strcat(pszMleBuf,"\n");
   strcat(pszMleBuf,"******************************\n");
   dataSize = strlen(pszMleBuf);
   cbCopied = (ULONG) WinSendMsg(hwndMle,
                                 MLM_IMPORT,
                                 MPFROMP( &lOffset),
                                 MPFROMLONG(dataSize));
   free((PVOID) pszMleBuf);
}