Exemplo n.º 1
0
gboolean change_volume(gpointer data)
{
    printf("---------------------------change volume\n");
    send_panel_message();
    printf("---------------------------change end\n");

    return FALSE;
}
void
button_callback (MBTrayApp *app, int x, int y, Bool is_released )
{
  int abs_x, abs_y;
  Bool do_anim = False;

  ButtonIsDown = True;
  if (is_released)
    {
      ButtonIsDown = False;
      mb_tray_app_repaint (app);
      switch (action)
	{
	case ACTION_NONE:
	  fork_exec(cmd_str);
	  do_anim = DoAnimation;
	  break;
	case ACTION_KILL:
	  if (win_launched && win_exists(win_launched, mb_tray_app_xrootwin(app)))
	    {
	      kill_launched_win(win_launched);
	      win_launched = None;
	    } else {
	      fork_exec(cmd_str);
	      win_launched = get_launch_window();
	    }
	  break;
	case ACTION_TOGGLE_WIN_STATE:
	  if (win_launched && win_exists(win_launched, mb_tray_app_xrootwin(app)))
	    {
	      XWindowAttributes win_attrib;
	      XGetWindowAttributes(dpy, win_launched, &win_attrib);
	      
	      if (win_attrib.map_state == IsUnmapped ||
		  get_win_state(win_launched) != NormalState)
		XMapRaised(dpy, win_launched);
	      else
		XIconifyWindow(dpy, win_launched, screen);
	    }
	  else
	    {
	      fork_exec(cmd_str);
	      win_launched = get_launch_window();
	    }
	  break;
	case ACTION_MESSAGE_DOCK:
	  send_panel_message(cmd_str);
	  break;
#ifdef USE_LIBSN
	case ACTION_SN:
	  do_anim = DoAnimation;
	  sn_activate(win_panel_title, cmd_str);
	  break;
	case ACTION_SI:
	  do_anim = DoAnimation;
	  si_activate(win_panel_title, cmd_str);
	  break;
#endif
	}

      if (do_anim)
	{
	  mb_tray_app_get_absolute_coords (app, &abs_x, &abs_y); 

	  mb_util_animate_startup(mb_tray_app_xdisplay (app), 
				  abs_x,
				  abs_y,
				  mb_tray_app_width (app),
				  mb_tray_app_height (app));
	}
    } else mb_tray_app_repaint (app);


}
Exemplo n.º 3
0
unsigned long HFPMsgCallBack(HFPEVENT event, void* lpParam, unsigned long param)
{
    printf("HFPMsgCallBack:%d\n",event);

    switch (event)
    {
    case RING_EVENT:
    {
        return 1;
    }
    break;
	case SMS_SUCCESS:
	{
		printf("send sms success\n");
		system("dbus-send / com.asianux.sms.succesd ");
		system("dbus-send / com.asianux.fom.succesd ");
	}
	break;
	case SMS_FAILED:
	{
		system("dbus-send / com.asianux.sms.failed ");
		system("dbus-send / com.asianux.fom.failed ");
		printf("sms sms filed\n");
	}
	break;
    case PHONESTATUS_EVENT:
    {
        PHONESTATUS status = (PHONESTATUS)param;
        switch (status)
        {
        case CALLINCOMING:
        {
			printf("-----call  in  -----\n");

            return 0;
        }
        break;
        case CALLOUTGOING:
		{
			printf("-----call  out -----\n");
			
            usleep(1200);
			
			send_panel_message();
			
//			app_agent_set_play(appAgent);

			is_calling = TRUE;

        }
        break;
        case CALLACTIVE:
        {
			printf("-----call active-----\n");
            DBusMessage *message;
            dbus_uint32_t serial = 0;

            message = dbus_message_new_signal("/","com.asianux.notification","begin");
            if (!dbus_connection_send(dbus_conn,message,&serial))
            {
                exit(1);
            }

            dbus_connection_flush(dbus_conn);
            dbus_message_unref(message);

//			app_agent_set_play(appAgent);

            send_panel_message();

            is_calling = TRUE;

        }
        break;
        case CALLINACTIVE:
        {
			printf("-----call end-----\n");

			if(is_calling == TRUE)
			{
				printf("-----end---\n\n");
	            DBusMessage *msg;
		        dbus_uint32_t serial_1 = 0;
			    msg = dbus_message_new_signal("/","com.asianux.notification","end");

				if (!dbus_connection_send(dbus_conn,msg,&serial_1))
				{
					printf("-----send end notification failed-----\n");
					exit(1);
				}

	            dbus_connection_flush(dbus_conn);
		        dbus_message_unref(msg);
			}
		    else
			{
				printf("----hook----\n\n");
				DBusMessage *msg2;
				dbus_uint32_t serial_2 =0;
				msg2 = dbus_message_new_signal("/","com.asianux.notification","hook");

				if(!dbus_connection_send(dbus_conn,msg2,&serial_2))
				{
					printf("-------send hook notification failed-----\n");
					exit(1);
				}

				dbus_connection_flush(dbus_conn);
				dbus_message_unref(msg2);
			}

//			app_agent_set_stop(appAgent);

            is_calling = FALSE;
            is_new = FALSE;

            //    printf("##############################end\n");

        }
        break;
        }
    }
    break;
    case CALLERNUMBER_EVENT:	//呼叫着电话号码
    {

        char number[512];

        sprintf(number," dbus-send / com.asianux.notification.notify string:dial string:%s string: string: ",param);

        if (!is_new)
        {
            system(number);
            is_new = TRUE;
        }
        return 1;
    }
    break;
    case SMMT_EVENT:
    {
		printf("----param is %s-----\n",param);

		const char *pconstChar =(const char *)param;

	    char test[1024];
		
		sprintf(test,"%s",pconstChar);

		printf("****************%s\n",test);
		
		int length = strlen(pconstChar);

        if (length == 0)
		{
			return 1;
		}
	
        char *sms =(char *)malloc(sizeof(char)*(length+1));

        strcpy(sms,pconstChar);

		printf("------%s--------------%s\n",sms,pconstChar);

        char *pchar[3];

        pchar[0] = pchar[1] = pchar[2]=0;

        int pos=0;

        pchar[0] = sms;
        int itmp = 1;

        pos = strcspn(sms,";");
	
		while (pos<length)
        {
            pchar[itmp-1][pos] ='\0';
			pchar[itmp] = pchar[itmp-1]+pos+1;
            length-=(pos)+1;
        }
	
        pos = strcspn(pchar[itmp],";");

        pchar[itmp][pos]='\0';
        pchar[itmp+1]=pchar[itmp]+pos+1;

        printf("收到短信(rev sm):%s ##  %s ##  %s  %s\n", pchar[0],pchar[1],pchar[2],sms);

        char *sms_fom =(char *)malloc(512);
        sms_fom = strdup(pchar[2]);

        int index = 0;
        char *sms_str[3];
        sms_str[0] = sms_str[1] = sms_str[2]=0;
        sms_str[0] =sms_fom;

        index = strcspn(sms_fom,":");


        if (index == 3)
        {
			
            sms_str[0][index] = '\0';
            sms_str[1] =sms_str[0]+index+1;

            if (strcmp(sms_str[0],"tas") == 0)
            {
                char *number = (char *)malloc(64);

                strncpy(number,sms_str[1],3);

                char *message = (char *)malloc(1024);
			
                sprintf(message,"dbus-send  / com.asianux.smsterm.sms string:\"%s\"",strdup(test));

				printf("==============%s\n",message);

                system(message);

                free(message);
                message = NULL;

                free(number);
                number = NULL;

                return 1;
            }
            else
            {

                char *errMsg = NULL;
                char sql[500];

                int ret = sqlite3_open("/root/.sms.db",&db);
                if (ret == SQLITE_OK)
                {
                }
                else
                {
                    //                  printf("open database failed\n");
                }

                time(&sms_time);

                char *number =(char *) malloc(50);
                char *time = (char *)malloc(50);
                char *text = (char *)malloc(1024);
                char *content = (char *)malloc(1024);
                char *filter_number = (char *)malloc(50);
                char *filter_sms = (char *)malloc(1024);

                number = strdup(pchar[0]);
                time = strdup(pchar[1]);
                text = strdup(pchar[2]);

                int i=0;
                int j = 0;

                for (; i<strlen(text); i++)
                {
                    if (text[i] =='\n' || text[i] =='\r')
                    {
                        content[j]=' ';
                    }
                    else if (text[i] == '\'')
                    {
                        content[j] =='\'';
                        j++;
                        content[j]='\'';
                    }
                    else
                    {
                        content[j]=text[i];
                    }
                    j++;
                }

                content[j] = '\0';

                int m=0;
                int n=0;

                for (; n<strlen(text); n++)
                {
                    if (text[n] =='\n' || text[n] =='\r')
                    {
                        filter_sms[m]=' ';
                    }
                    else if (text[n] == '\'' || text[n] == '\"')
                    {
                        filter_sms[m]=' ';
                    }
                    else
                    {
                        filter_sms[m]=text[n];
                    }
                    m++;
                }

                filter_sms[m]='\0';

                char *str= NULL;
                str = strstr(number,"+86");
                if (str)
                {
                    int j=3;
                    int m = 0;

                    for (; number[j] != '\0'; j++)
                    {
                        filter_number[m]=number[j];
                        m++;
                    }

                    filter_number[m]='\0';

                }
                else
                {
                    filter_number = strdup(number);
                }

                sprintf(sql,"INSERT INTO \"sms\" VALUES(NULL,1,'%s',NULL,'%s\n','%s',1,%ld);",filter_number,content,time,sms_time);
                ret = sqlite3_exec(db,sql,0,0,&errMsg);

                if (ret == SQLITE_OK)
                {
                    sqlite3_close(db);
                    free(sms);
                    sms = NULL;

                    char *send = (char *)malloc((1024)*sizeof(char));
                    sprintf(send,"dbus-send / com.asianux.notification.notify string:\"sms\" string:\"%s\" string:\"%s\" string:\"%s\"",number,filter_sms,time);

                    system(send);

                    free(send);
                    send = NULL;

                    free(number);
                    free(time);
                    free(text);
                    free(content);
                    free(filter_number);
                    free(filter_sms);
                    number = NULL;
                    time = NULL;
                    text = NULL;
                    content = NULL;
                    filter_number = NULL;
                    filter_sms = NULL;

                    return 1;
                }
                else
                {
                    sqlite3_close(db);
                    free(sms);
                    sms = NULL;
                    free(number);
                    free(time);
                    free(text);
                    free(content);
                    free(filter_number);
                    free(filter_sms);
                    number = NULL;
                    time = NULL;
                    text = NULL;
                    content = NULL;
                    filter_number = NULL;
                    filter_sms = NULL;
                    return 0;
                }

            }

        }
        else
        {

            char *errMsg = NULL;
            char sql[500];

            int ret = sqlite3_open("/root/.sms.db",&db);
            if (ret == SQLITE_OK)
            {
            }
            else
            {
            }

            time(&sms_time);

            char *number =(char *) malloc(50);
            char *time = (char *)malloc(50);
            char *text = (char *)malloc(1024);
            char *content = (char *)malloc(1024);
            char *filter_number = (char *)malloc(50);
            char *filter_sms = (char *)malloc(1024);

            number = strdup(pchar[0]);
            time = strdup(pchar[1]);
            text = strdup(pchar[2]);

            int i=0;
            int j=0;

            for (; i<strlen(text); i++)
            {
                if (text[i] =='\n' || text[i] =='\r')
                {
                    content[j]=' ';
                }
                else if (text[i] == '\'')
                {
                    content[j]='\'';
                    j++;
                    content[j] = '\'';
                }
                else
                {
                    content[j]=text[i];
                }
                j++;
            }

            content[j]='\0';

            int m=0;
            int n=0;

            for (; n<strlen(text); n++)
            {
                if (text[n] =='\n' || text[n] =='\r')
                {
                    filter_sms[m]=' ';
                }
                else if (text[n] == '\'' || text[n] == '\"')
                {
                    filter_sms[m]=' ';
                }
                else
                {
                    filter_sms[m]=text[n];
                }
                m++;
            }

            filter_sms[m]='\0';

            char *str= NULL;
            str = strstr(number,"+86");
            if (str)
            {
                int j=3;
                int m = 0;

                for (; number[j] != '\0'; j++)
                {
                    filter_number[m]=number[j];
                    m++;
                }

                filter_number[m]='\0';


            }
            else
            {
                filter_number = strdup(number);

            }

            sprintf(sql,"INSERT INTO \"sms\" VALUES(NULL,1,'%s',NULL,'%s\n','%s',1,%ld);",filter_number,content,time,sms_time);

            ret = sqlite3_exec(db,sql,0,0,&errMsg);

            if (ret == SQLITE_OK)
            {
                sqlite3_close(db);
                free(sms);
                sms = NULL;

                char *send = (char *)malloc((1024)*sizeof(char));
                sprintf(send,"dbus-send  / com.asianux.notification.notify string:sms string:\"%s\" string:\"%s\" string:\"%s\"",number,filter_sms,time);

                system(send);

                free(send);
                send = NULL;
                free(number);
                free(time);
                free(text);
                free(content);
                free(filter_number);
                free(filter_sms);
                number = NULL;
                time = NULL;
                text = NULL;
                content = NULL;
                filter_number = NULL;
                filter_sms = NULL;
                return 1;
            }
            else
            {
                sqlite3_close(db);
                free(sms);
                sms = NULL;
                free(number);
                free(time);
                free(text);
                free(content);
                free(filter_number);
                free(filter_sms);
                number = NULL;
                time = NULL;
                text = NULL;
                content = NULL;
                filter_number = NULL;
                filter_sms = NULL;
                return 0;
            }


        }
        
		free(sms_fom);
        sms_fom = NULL;

    }
    break;
	}
}