Esempio n. 1
0
// What we wish to do here:  Check for an active Send Message dialog
// that contains the callsign of interest.  If one doesn't exist,
// create one and pop it up.  We don't want to do this for duplicate
// message lines or duplicate acks for any particular QSO.  To do so
// would cause the Send Message dialog to pop up on every such
// received message, which is VERY annoying (that was the default in
// Xastir for years, and nobody liked it!).
//
int check_popup_window(char *from_call_sign, int group) {
    int i,found,j,ret;
    char temp1[MAX_CALLSIGN+1];
    char *temp_ptr;


//fprintf(stderr,"\tcheck_popup_window()\n");

    ret = -1;
    found = -1;

begin_critical_section(&send_message_dialog_lock, "messages.c:check_popup_window" );

    // Check for an already-created dialog for talking to this
    // particular call_sign.
    //
    for (i = 0; i < MAX_MESSAGE_WINDOWS; i++) {

        if (mw[i].send_message_dialog != NULL) { // If dialog created

            temp_ptr = XmTextFieldGetString(mw[i].send_message_call_data);
            xastir_snprintf(temp1,
                sizeof(temp1),
                "%s",
                temp_ptr);
            XtFree(temp_ptr);

            /*fprintf(stderr,"Looking at call <%s> for <%s>\n",temp1,from_call_sign);*/
            if (strcasecmp(temp1, from_call_sign) == 0) {
                // Found a call_sign match in a Send Message dialog!

//fprintf(stderr,"\tFound a Send_message dialog match\n");

                found = i;
                break;
            }
        }
    }

end_critical_section(&send_message_dialog_lock, "messages.c:check_popup_window" );

    // If found == -1 at this point, we haven't found a Send Message
    // dialog that contains the call_sign of interest.
    //
    if (found == -1 && (group == 2 || group_active(from_call_sign))) {
        /* no window found Open one! */

//fprintf(stderr,"\tNo Send Message dialog found, creating one\n");

begin_critical_section(&send_message_dialog_lock, "messages.c:check_popup_window2" );

        i= -1;
        for (j=0; j<MAX_MESSAGE_WINDOWS; j++) {
            if (!mw[j].send_message_dialog) {
                i=j;
                break;
            }
        }

end_critical_section(&send_message_dialog_lock, "messages.c:check_popup_window2" );

        if (i!= -1) {

            if (group == 1) {
                temp1[0] = '*';
                temp1[1] = '\0';
            }
            else {
                temp1[0] = '\0';
            }

            strncat(temp1,
                from_call_sign,
                sizeof(temp1) - 1 - strlen(temp1));

            if (!disable_all_popups) {
                Send_message(appshell, temp1, NULL);
            }

            update_messages(1);

            ret=i;
        }
        else {
            fprintf(stderr,"No open windows!\n");
        }
    }
    else {
        /* window open! */
        // Pop it up
        ret=found;
    }

    if (found != -1) {  // Already have a window
        XtPopup(mw[i].send_message_dialog,XtGrabNone);
    }

    return(ret);
}
Esempio n. 2
0
interrupt(TIMERB0_VECTOR) Timer_B0(void)
{
	etat.Counter--;
	if(etat.Counter == 0){
		Start_Timer_Surveille();		//the timer A0 is closed when we use CCA, we must check it and start it
		Stop_Timer();
		if(etat.state == WAIT_SCAN && etat.ID_Network == NO_NETWORK){
	 		etat.ID_Network = etat.MAC;
	  		etat.HOST = IS_CREATER;
		 	etat.synchrone = 1;			 
			etat.state = WAIT_SYNCHRONE;		//change the state
			timer_synchrone(&etat);
			Send_beacon(&etat);
			P1OUT |= 0x02;   			//jaune led
	 	}else{
			switch(etat.state){
				case WAIT_BEACON : 
					if(etat.HOST == IS_NOT_CREATER){
						etat.state = WAIT_SYNCHRONE;	//change the state
						if(etat.ID_Beacon < etat.MAC){
							timer_synchrone(&etat);
							P1OUT ^= 0x01;   			//rouge led
							Send_beacon(&etat);			//send beacon
						}else{			
							Stop_Timer();	
						}
					}
					break;
				case WAIT_SYNCHRONE : 
					etat.state = WAIT_MESSAGE;	//change the state
					//time for message
					timer_message(&etat);	
					if(etat.HOST == IS_NOT_CREATER ){
					 	etat.synchrone = 0;			 
					}

					if(etat.Dst != 0){
						Send_message(&etat, &etat.FIFO_Send ,etat.Dst);
					}
					Recieve_message(&etat, &etat.FIFO_Recieve);

					if(RIP_Prepared == 1){			//every 3s ,send the rip
						Tidy_table(&etat);		// clear the dirty data
						Send_rip(&etat);
						RIP_Prepared = 0;
					}
					break;
				case WAIT_MESSAGE :
					etat.state = WAIT_SLEEP;	//change the state
					//time for sleep
					timer_sleep(&etat);
					Sleep();
					break;
				case WAIT_SLEEP :
					if(etat.HOST == IS_NOT_CREATER ){
						etat.state = WAIT_BEACON;	//change the state

						if(etat.ID_Beacon < etat.MAC){
							Stop_Timer();
						}else{
							timer_send_beacon(&etat);
						}
					}else{						//the host
						etat.state = WAIT_SYNCHRONE;
						timer_synchrone(&etat);
						P1OUT ^= 0x01;   			//rouge led
						Send_beacon(&etat);
					}
					break;
				default:
					break;		
			}
		}

	}
}
Esempio n. 3
0
void svc(SYSTEM_CALL_DATA *SystemCallData) {
	MEMORY_MAPPED_IO mmio; 
	short call_type;
	static short do_print = 10;
	INT32 Time;
	INT32 Status;
	short i;
	long* arg0=SystemCallData->Argument[0];
	long* arg1=SystemCallData->Argument[1];
	long* arg2=SystemCallData->Argument[2];
	long* arg3=SystemCallData->Argument[3];
	long* arg4=SystemCallData->Argument[4];
	long *arg5=SystemCallData->Argument[5];
	call_type = (short) SystemCallData->SystemCallNumber;
	if (do_print > 0) {
		printf("SVC handler: %s\n", call_names[call_type]);
		for (i = 0; i < SystemCallData->NumberOfArguments - 1; i++) {
			printf("Arg %d: Contents = (Decimal) %8ld,  (Hex) %8lX\n", i,
					(unsigned long) SystemCallData->Argument[i],
					(unsigned long) SystemCallData->Argument[i]);
		} 
		do_print--;
	}

	switch (call_type) {
		// Get time service call
		case SYSNUM_GET_TIME_OF_DAY:
			mmio.Mode = Z502ReturnValue;
			mmio.Field1 = mmio.Field2 = mmio.Field3 = 0;
			MEM_READ(Z502Clock, &mmio);//hardware call
			Time = mmio.Field1;
			(SystemCallData->Argument[0])=(long*)&Time;

			//statePrinter(call_type,arg0, arg1, arg2, arg3, arg4);
			break;
				// get the Timer start and generate idle.
		case SYSNUM_SLEEP:

			startTimer(arg0);

			//statePrinter(call_type,arg0, arg1, arg2, arg3, arg4);

			Dispatcher();//call dispatcher	

			break;

		// create process
		case SYSNUM_CREATE_PROCESS:
			OSCreateProcess(arg0,arg1,arg2,arg3,arg4);
			//statePrinter(call_type,arg0, arg1, arg2, arg3, arg4);
			break;

		// get process id
		case SYSNUM_GET_PROCESS_ID:
			getProcessID(arg0,arg1,arg2);
			//statePrinter(call_type,arg0, arg1, arg2, arg3, arg4);
			break;

		// suspend process
		case SYSNUM_SUSPEND_PROCESS:
			suspendProcess(arg0, arg1);
			//statePrinter(call_type,arg0, arg1, arg2, arg3, arg4);
			break;
		
		// resume the process
		case SYSNUM_RESUME_PROCESS:
			resumeProcess(arg0, arg1);
			//statePrinter(call_type,arg0, arg1, arg2, arg3, arg4);
			break;
		
		// change priority;
		case SYSNUM_CHANGE_PRIORITY:
			changePriority(arg0,arg1,arg2);
			//statePrinter(call_type,arg0, arg1, arg2, arg3, arg4);
			break;

		// terminate system call
		case SYSNUM_TERMINATE_PROCESS:
			terminateSysProcess(arg0,arg1);
			break;

		case SYSNUM_SEND_MESSAGE:
			Send_message(arg0, arg1, arg2, arg3);

			break;

		case SYSNUM_RECEIVE_MESSAGE:
			ReceiveMessage(arg0, arg1, arg2, arg3, arg4, arg5);
			break;
		
		case SYSNUM_DISK_WRITE:
			DiskWrite(arg0, arg1, arg2);
			break;

		case SYSNUM_DISK_READ:
			DiskRead(arg0, arg1, arg2);
			break;

		case SYSNUM_DEFINE_SHARED_AREA:
			DefineSharedArea(arg0, arg1, arg2,arg3,arg4);
			break;

		default:
			printf( "ERROR!  call_type not recognized!\n" ); 
			printf( "Call_type is - %i\n", call_type);

	}
}                                               // End of svc