void NotificationManager::RequestNotifications(BMessage *msg) { BMessenger messenger; const media_node *node; ssize_t nodeSize; team_id team; int32 what; msg->FindMessenger(NOTIFICATION_PARAM_MESSENGER, &messenger); msg->FindInt32(NOTIFICATION_PARAM_TEAM, &team); msg->FindInt32(NOTIFICATION_PARAM_WHAT, &what); msg->FindData("node", B_RAW_TYPE, reinterpret_cast<const void **>(&node), &nodeSize); ASSERT(nodeSize == sizeof(media_node)); Notification n; n.messenger = messenger; n.node = *node; n.what = what; n.team = team; TRACE("NotificationManager::RequestNotifications node %ld, team %ld, " "what %#lx\n",node->node, team, what); fLocker.Lock(); fNotificationList.Insert(n); fLocker.Unlock(); // send the initial B_MEDIA_NODE_CREATED containing all existing live nodes BMessage initmsg(B_MEDIA_NODE_CREATED); if (gNodeManager->GetLiveNodes(&initmsg) == B_OK) messenger.SendMessage(&initmsg, static_cast<BHandler *>(NULL), TIMEOUT); }
void printm(int nub,struct msg_st *m) { if(nub > 255 || nub < 0 || !m) { printf("printm error !\n"); exit(1); } if(msgids[nub] < 0) initmsg(nub); m->msg_type = 1984; if(msgsnd(msgids[nub], (void*)m, 256, IPC_NOWAIT) < 0) { perror("msgsnd ERROR "); exit(1); } }
void notify(DBusMessage *dmsg) { DBusMessage *reply; DBusMessageIter args; DBusMessageIter hints; DBusMessageIter hint; char *hint_name; int i; int id = 23; const char *appname = NULL; const char *summary = NULL; const char *body = NULL; const char *icon = NULL; const char *fgcolor = NULL; const char *bgcolor = NULL; int urgency = 1; msg_queue_t *msg = malloc(sizeof(msg_queue_t)); dbus_uint32_t nid=0; dbus_int32_t expires=-1; dbus_serial++; dunst_printf(DEBUG, "new dbus message\n"); dbus_message_iter_init(dmsg, &args); dunst_printf(DEBUG, "extracting appname\n"); _extract_basic(DBUS_TYPE_STRING, &args, &appname); dbus_message_iter_next( &args ); dunst_printf(DEBUG, "extracting nid\n"); _extract_basic(DBUS_TYPE_UINT32, &args, &nid); dbus_message_iter_next( &args ); dunst_printf(DEBUG, "extracting icon\n"); _extract_basic(DBUS_TYPE_STRING, &args, &icon); dbus_message_iter_next( &args ); dunst_printf(DEBUG, "extracting summary\n"); _extract_basic(DBUS_TYPE_STRING, &args, &summary); dbus_message_iter_next( &args ); dunst_printf(DEBUG, "extracting body\n"); _extract_basic(DBUS_TYPE_STRING, &args, &body); dbus_message_iter_next( &args ); dbus_message_iter_next( &args ); dunst_printf(DEBUG, "extracting hints\n"); dbus_message_iter_recurse(&args, &hints); dbus_message_iter_next( &args ); dunst_printf(DEBUG, "extracting expires\n"); _extract_basic(DBUS_TYPE_INT32, &args, &expires); dunst_printf(DEBUG, "extracting hints\n"); while (dbus_message_iter_get_arg_type(&hints) != DBUS_TYPE_INVALID) { dbus_message_iter_recurse(&hints, &hint); while (dbus_message_iter_get_arg_type(&hint) != DBUS_TYPE_INVALID) { if(dbus_message_iter_get_arg_type(&hint) != DBUS_TYPE_STRING) { dbus_message_iter_next(&hint); continue; } dbus_message_iter_get_basic(&hint, &hint_name); _extract_hint("urgency", hint_name, &hint, &urgency); _extract_hint("fgcolor", hint_name, &hint, &fgcolor); _extract_hint("bgcolor", hint_name, &hint, &bgcolor); dbus_message_iter_next(&hint); } dbus_message_iter_next(&hints); } if(expires > 0) { /* do some rounding */ expires = (expires+500)/1000; if(expires < 1) { expires = 1; } } msg->appname = strdup(appname); msg->summary = strdup(summary); msg->body = strdup(body); msg->icon = strdup(icon); msg->timeout = expires; msg->urgency = urgency; for(i = 0; i < ColLast; i++) { msg->color_strings[i] = NULL; } msg->color_strings[ColFG] = fgcolor == NULL ? NULL : strdup(fgcolor); msg->color_strings[ColBG] = bgcolor == NULL ? NULL : strdup(bgcolor); initmsg(msg); msgqueue = add(msgqueue, msg); drawmsg(); reply = dbus_message_new_method_return(dmsg); dbus_message_iter_init_append(reply, &args); dbus_message_iter_append_basic(&args, DBUS_TYPE_UINT32, &id); dbus_connection_send(dbus_conn, reply, &dbus_serial); dbus_message_unref(reply); }
msgmenu() { char prompt[80],s[80],k[80]; int i; cur=i=0; initmsg(); if(user.sl < bidx[0].level) { nl(); nl(); put("4You can't access the first section"); return; } if(bidx[0].pass[0]!=0) { put("1Enter file base password:2 "); input(s,50); nl(); if(stricmp(bidx[0].pass,s)!=0) { pl("4Sorry, wrong password"); return; } } if(dispnoerr("MWELC.ANS")==-1) { put_char(12); put("4"); print("���������������������������������������ķ"); nl(); print("� Conference: �"); nl(); print("� Current Base: �"); nl(); print("���������������������������������������Ķ"); nl(); print("� Total Msgs: �"); nl(); print("� Last Read : �"); nl(); print("���������������������������������������Ľ"); nl(); ccursor(2,15); print("2%d - %s",cidx[curconf].num,cidx[curconf].name); ccursor(3,17); print("2%d - %s",bidx[cur].num,bidx[cur].name); gettotalmsgs(); ccursor(5,15); print("3%d",totalmsgs); ccursor(6,15); print("30"); nl(); nl(); nl(); } gettotalmsgs(); while(1) { nl(); setmci(1); print("4[1%d left4 * [3Area %d4] 1Message Menu4]:2 ",chktime()/60,bidx[cur].num); setmci(0); input(s,50); strupr(s); switch(s[0]) { case 'R': readpost(); break; case 'P': post(); break; case 'A': printboard(); break; case 'G': logoff(); break; case '?': do_help("MSG"); break; case 'J': confmenu(); msgmenu(); break; case '!': if(user.sl > 200) msgsysop(); break; case 'Q': return; default: if(isdigit(s[0])) { i=atoi(s); if(i <= numread && i > 0 && user.sl >= bidx[i-1].level) { if(fileidx[i-1].pass[0]!=0) { nl(); put("1Enter file base password:2 "); input(k,50); if(stricmp(bidx[i-1].pass,k)!=0) { nl(); pl("4Sorry, wrong password"); } else { cur=i-1; gettotalmsgs(); } } else { cur=i-1; gettotalmsgs(); } } } break; } } }
int main(int argc,char *argv[]) { /** 初始化全局共享内存前,先获取ups根路径 **/ if(setupshome()==-1) { printf("设置全局变量upshome错误,请检查UPSHOME环境变量是否设置\n"); return -1; } size_t shmsize; FILE *fp; char tmpbuf[100]; char chnlcfgpath[100]; memset(tmpbuf,0,sizeof(tmpbuf)); memset(chnlcfgpath,0,sizeof(chnlcfgpath)); /** init the sysparam shm cfg **/ shmsize = 3*sizeof(_sys_param); if(getshm(3,shmsize)==-1) { printf("获取系统公用参数共享内存失败\n"); return -1; } shmsize = HASHCNT*BUCKETSCNT*sizeof(_tran); /** init tran shm **/ if(getshm(10,shmsize)==-1) { printf("获取交易hash桶共享内存ID失败\n"); return -1; } /** init commmsg **/ shmsize=MAXCOMMMSG*sizeof(_commmsg); if(getshm(9,shmsize)==-1) { printf("获取渠道间通信共享内存ID失败\n"); return -1; } /** init flow **/ shmsize=MAXFLOW*sizeof(_flow); if(getshm(8,shmsize)==-1) { printf("获取流程配置区共享内存ID失败\n"); return -1; } /** init server reg **/ shmsize = MAXSERVREG*sizeof(_servreg); if(getshm(7,shmsize)==-1) { printf("获取交易系统服务登记共享内存ID失败\n"); return -1; } /** init xml cfg **/ shmsize = MAXXMLCFG*sizeof(_xmlcfg); if(getshm(6,shmsize)==-1) { printf("获取XML配置共享内存失败\n"); return -1; } /** init tran map cfg **/ shmsize = MAXTRANMAP*sizeof(_tranmap); if(getshm(5,shmsize)==-1) { printf("获取交易码映射配置共享内存失败\n"); return -1; } /** init the vardef shm cfg **/ shmsize = MAXVARDEF*sizeof(_vardef); if(getshm(4,shmsize)==-1) { printf("获取变量定义映射配置共享内存失败\n"); return -1; } /** 初始化系统所有渠道的队列区 **/ sprintf(chnlcfgpath,"%s%s",upshome,"/cfg/chnl.cfg"); fp = fopen(chnlcfgpath,"r"); if(fp == NULL) { printf("打开渠道初始化配置文件失败:[%s]\n",strerror(errno)); return -1; } while(fgets(tmpbuf,sizeof(tmpbuf),fp)!=NULL) { tmpbuf[strlen(tmpbuf)-1]='\0'; if(tmpbuf[0]=='*') continue; else if(tmpbuf[0]=='@') { if(initmsg(tmpbuf+1)!=0) { printf("初始化:[%s]渠道队列区失败\n",tmpbuf+1); return -1; } printf("初始化:[%s]渠道队列区成功\n",tmpbuf+1); }else { continue; } } fclose(fp); /** init sem **/ if(initservregsem()!=0) { printf("获取服务登记区信号灯失败\n"); return -1; }else { printf("获取服务登记区信号灯成功\n"); } /** system v sem if(init_sem(1)==0) { SysLog(LOG_SYS_ERR,"init sem ok\n"); }else { SysLog(LOG_SYS_ERR,"init sem error\n"); return -1; } **/ return 0; }