void createSTBMsgQs(void) { queue_conf_t *pQueue = &startup_queues[0]; int i, n; for (i = 0, n = 0; pQueue->pQid != NULL; i++, pQueue++) { #ifdef _STB_CONF_DEBUG_ tprint0n("creating Queue %8.8s ...", pQueue->name); #endif *pQueue->pQid = createMsg(pQueue->name, pQueue->max_num, pQueue->max_len, pQueue->priority ); if (*pQueue->pQid == NULL) { int err=0; #ifdef _VXWORKS_ err = errnoGet(); #endif /* _VXWORKS_ */ printf("Create Queue[%8.8s] failed errno %08x\n", pQueue->name, err); } else { #ifdef _STB_CONF_DEBUG_ rprint1n(" qid is 0x%08x", *pQueue->pQid); #endif n++; } } dbgprint("%3d Message queues are created", n); return; }
void loop(){ createMsg(); int t1; int l; int letter; for(letter=0; letter< MAX_MSG; letter++) { for(l=0;l< LETTER_TIME;l++) { for(t1=0;t1<8;t1++) { displayNum(outStr[letter][t1],(t1+1)); } } if (letter == msgLen+4) { break; } } // for (int row=0; row<8; row++) { // digitalWrite(row1+row, HIGH); // for (int col=0; col<8; col++) { // digitalWrite(col1+col, LOW); // } // } }
/** Constructor */ CreateForumMsg::CreateForumMsg(const std::string &fId, const std::string &pId) : QDialog(NULL), mForumId(fId), mParentId(pId) { /* Invoke the Qt Designer generated object setup routine */ ui.setupUi(this); setAttribute(Qt::WA_DeleteOnClose, true); QString text = pId.empty() ? tr("Start New Thread") : tr("Post Forum Message"); setWindowTitle(text); ui.headerFrame->setHeaderImage(QPixmap(":/images/konversation64.png")); ui.headerFrame->setHeaderText(text); Settings->loadWidgetInformation(this); connect( ui.forumMessage, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( forumMessageCostumPopupMenu( QPoint ) ) ); connect(ui.hashBox, SIGNAL(fileHashingFinished(QList<HashedFile>)), this, SLOT(fileHashingFinished(QList<HashedFile>))); // connect up the buttons. connect( ui.buttonBox, SIGNAL(accepted()), this, SLOT(createMsg())); connect( ui.buttonBox, SIGNAL(rejected()), this, SLOT(close())); connect( ui.emoticonButton, SIGNAL(clicked()), this, SLOT(smileyWidgetForums())); connect( ui.attachFileButton, SIGNAL(clicked() ), this , SLOT(addFile())); connect( ui.pastersButton, SIGNAL(clicked() ), this , SLOT(pasteLink())); setAcceptDrops(true); ui.hashBox->setDropWidget(this); ui.hashBox->setAutoHide(false); newMsg(); }
void QQParseThread::run() { while (true) { poll_done_smp_->acquire(); Json::Reader reader; Json::Value root; QByteArray unparse_msg = message_queue_->dequeue(); qDebug()<<unparse_msg<<endl; int idx = unparse_msg.indexOf("\r\n\r\n"); unparse_msg = unparse_msg.mid(idx+4); if (!reader.parse(QString(unparse_msg).toStdString(), root, false)) { continue; } qDebug()<<"reader parse done"<<endl; if (root["retcode"].asInt() == 121) { //ÀëÏß } for (unsigned int i = 0; i < root["result"].size(); ++i) { const Json::Value result = root["result"][i]; QString type = QString::fromStdString(result["poll_type"].asString()); QQMsg *msg = createMsg(type, result); if (msg) emit parseDone(msg); } } }
/** Constructor */ GxsChannelDialog::GxsChannelDialog(QWidget *parent) : RsGxsUpdateBroadcastPage(rsGxsChannels, parent), GxsServiceDialog(dynamic_cast<GxsCommentContainer *>(parent)) { /* Invoke the Qt Designer generated object setup routine */ ui.setupUi(this); /* Setup UI helper */ mStateHelper = new UIStateHelper(this); mStateHelper->addWidget(TOKEN_TYPE_POSTS, ui.progressBar, UISTATE_LOADING_VISIBLE); mStateHelper->addWidget(TOKEN_TYPE_POSTS, ui.progressLabel, UISTATE_LOADING_VISIBLE); mStateHelper->addLoadPlaceholder(TOKEN_TYPE_GROUP_DATA, ui.nameLabel); mStateHelper->addWidget(TOKEN_TYPE_GROUP_DATA, ui.postButton); mStateHelper->addWidget(TOKEN_TYPE_GROUP_DATA, ui.logoLabel); mChannelQueue = new TokenQueue(rsGxsChannels->getTokenService(), this); connect(ui.postButton, SIGNAL(clicked()), this, SLOT(createMsg())); // connect(NotifyQt::getInstance(), SIGNAL(channelMsgReadSatusChanged(QString,QString,int)), this, SLOT(channelMsgReadSatusChanged(QString,QString,int))); /*************** Setup Left Hand Side (List of Channels) ****************/ connect(ui.treeWidget, SIGNAL(treeCustomContextMenuRequested(QPoint)), this, SLOT(channelListCustomPopupMenu(QPoint))); connect(ui.treeWidget, SIGNAL(treeCurrentItemChanged(QString)), this, SLOT(selectChannel(QString))); connect(ui.todoPushButton, SIGNAL(clicked()), this, SLOT(todo())); mChannelId.clear(); /* Set initial size the splitter */ QList<int> sizes; sizes << 300 << width(); // Qt calculates the right sizes ui.splitter->setSizes(sizes); /* Initialize group tree */ QToolButton *newChannelButton = new QToolButton(this); newChannelButton->setIcon(QIcon(":/images/add_channel24.png")); newChannelButton->setToolTip(tr("Create Channel")); connect(newChannelButton, SIGNAL(clicked()), this, SLOT(createChannel())); ui.treeWidget->addToolButton(newChannelButton); ownChannels = ui.treeWidget->addCategoryItem(tr("My Channels"), QIcon(IMAGE_CHANNELBLUE), true); subcribedChannels = ui.treeWidget->addCategoryItem(tr("Subscribed Channels"), QIcon(IMAGE_CHANNELRED), true); popularChannels = ui.treeWidget->addCategoryItem(tr("Popular Channels"), QIcon(IMAGE_CHANNELGREEN), false); otherChannels = ui.treeWidget->addCategoryItem(tr("Other Channels"), QIcon(IMAGE_CHANNELYELLOW), false); ui.progressLabel->hide(); ui.progressBar->hide(); ui.nameLabel->setMinimumWidth(20); /* load settings */ processSettings(true); /* Initialize empty GUI */ requestGroupData(mChannelId); }
void MsgProcessor::run() { while (true) { lock_.lock(); int rawmsg_count = message_queue_.count(); lock_.unlock(); if (rawmsg_count == 0) break; Json::Reader reader; Json::Value root; QByteArray unparse_msg = message_queue_.dequeue(); int idx = unparse_msg.indexOf("\r\n\r\n"); unparse_msg = unparse_msg.mid(idx+4); if (!reader.parse(QString(unparse_msg).toStdString(), root, false)) { continue; } qDebug()<<"recive msg"<<QString::fromStdString(root.toStyledString())<<endl; if (root["retcode"].asInt() == 121) { } QVector<QQMsg *> be_sorting_msg; for (unsigned int i = 0; i < root["result"].size(); ++i) { const Json::Value result = root["result"][i]; if ( isMsgRepeat(result) ) continue; QString type = QString::fromStdString(result["poll_type"].asString()); QQMsg *msg = createMsg(type, result); if ( msg ) be_sorting_msg.append(msg); } if ( be_sorting_msg.size() > 1 ) sortByTime(be_sorting_msg); dispatchMsg(be_sorting_msg); } }
int main(void) { int msgId; pid_t pid; pid = fork(); if(pid > 0) { int i; MsgBuf data; msgId = createMsg(KEY); MSG_ID = msgId; for(i = 0; i < 10; i++) { sleep(1); data.id = 1; sprintf(data.text, "Hello [%d]", i); if(msgsnd(msgId, &data, sizeof(MsgBuf), 0) < 0) { perror("msgsnd fail"); exit(-2); } } }else if(pid == 0) { sleep(1); MsgBuf data; msgId = getMsg(KEY); MSG_ID = msgId; while(1) { if(msgrcv(msgId, &data, sizeof(data), 1, 0) < 0) { perror("msgrcv fail"); exit(-2); } printf("data[%s] pid=%d\n", data.text, getpid()); } exit(0); }else { perror("Fork Error"); exit(-2); } }
void BlogsDialog::blogListCustomPopupMenu( QPoint point ) { BlogInfo bi; if (!rsBlogs->getBlogInfo(mBlogId, bi)) { return; } QMenu contextMnu( this ); QAction *createblogpostAct = new QAction(QIcon(":/images/mail_reply.png"), tr( "Post to Blog" ), this ); connect( createblogpostAct , SIGNAL( triggered() ), this, SLOT( createMsg() ) ); QAction *subscribeblogAct = new QAction(QIcon(":/images/edit_add24.png"), tr( "Subscribe to Blog" ), this ); connect( subscribeblogAct , SIGNAL( triggered() ), this, SLOT( subscribeBlog() ) ); QAction *unsubscribeblogAct = new QAction(QIcon(":/images/cancel.png"), tr( "Unsubscribe to Blog" ), this ); connect( unsubscribeblogAct , SIGNAL( triggered() ), this, SLOT( unsubscribeBlog() ) ); QAction *blogdetailsAct = new QAction(QIcon(":/images/info16.png"), tr( "Show Blog Details" ), this ); connect( blogdetailsAct , SIGNAL( triggered() ), this, SLOT( showBlogDetails() ) ); contextMnu.clear(); if (bi.blogFlags & RS_DISTRIB_PUBLISH) { contextMnu.addAction( createblogpostAct ); contextMnu.addSeparator(); contextMnu.addAction( blogdetailsAct ); } else if (bi.blogFlags & RS_DISTRIB_SUBSCRIBED) { contextMnu.addAction( unsubscribeblogAct ); contextMnu.addSeparator(); contextMnu.addAction( blogdetailsAct );; } else { contextMnu.addAction( subscribeblogAct ); contextMnu.addSeparator(); contextMnu.addAction( blogdetailsAct ); } contextMnu.exec(QCursor::pos()); }
/** Constructor */ ChannelFeed::ChannelFeed(QWidget *parent) : RsAutoUpdatePage(1000,parent) { /* Invoke the Qt Designer generated object setup routine */ setupUi(this); connect(newChannelButton, SIGNAL(clicked()), this, SLOT(createChannel())); connect(postButton, SIGNAL(clicked()), this, SLOT(createMsg())); connect(NotifyQt::getInstance(), SIGNAL(channelMsgReadSatusChanged(QString,QString,int)), this, SLOT(channelMsgReadSatusChanged(QString,QString,int))); /*************** Setup Left Hand Side (List of Channels) ****************/ connect(treeWidget, SIGNAL(treeCustomContextMenuRequested(QPoint)), this, SLOT( channelListCustomPopupMenu( QPoint ) ) ); connect(treeWidget, SIGNAL(treeCurrentItemChanged(QString)), this, SLOT(selectChannel(QString))); mChannelId.clear(); /* Set initial size the splitter */ QList<int> sizes; sizes << 300 << width(); // Qt calculates the right sizes splitter->setSizes(sizes); /* Initialize group tree */ treeWidget->initDisplayMenu(displayButton); ownChannels = treeWidget->addCategoryItem(tr("My Channels"), QIcon(IMAGE_CHANNELBLUE), true); subcribedChannels = treeWidget->addCategoryItem(tr("Subscribed Channels"), QIcon(IMAGE_CHANNELRED), true); popularChannels = treeWidget->addCategoryItem(tr("Popular Channels"), QIcon(IMAGE_CHANNELGREEN ), false); otherChannels = treeWidget->addCategoryItem(tr("Other Channels"), QIcon(IMAGE_CHANNELYELLOW), false); progressLabel->hide(); progressBar->hide(); fillThread = NULL; //added from ahead updateChannelList(); nameLabel->setMinimumWidth(20); /* load settings */ processSettings(true); updateChannelMsgs(); }
/** Constructor */ GxsChannelPostsWidget::GxsChannelPostsWidget(const RsGxsGroupId &channelId, QWidget *parent) : GxsMessageFramePostWidget(rsGxsChannels, parent), ui(new Ui::GxsChannelPostsWidget) { /* Invoke the Qt Designer generated object setup routine */ ui->setupUi(this); /* Setup UI helper */ mStateHelper->addWidget(mTokenTypeAllPosts, ui->progressBar, UISTATE_LOADING_VISIBLE); mStateHelper->addWidget(mTokenTypeAllPosts, ui->loadingLabel, UISTATE_LOADING_VISIBLE); mStateHelper->addWidget(mTokenTypeAllPosts, ui->filterLineEdit); mStateHelper->addWidget(mTokenTypePosts, ui->loadingLabel, UISTATE_LOADING_VISIBLE); mStateHelper->addLoadPlaceholder(mTokenTypeGroupData, ui->nameLabel); mStateHelper->addWidget(mTokenTypeGroupData, ui->postButton); mStateHelper->addWidget(mTokenTypeGroupData, ui->logoLabel); mStateHelper->addWidget(mTokenTypeGroupData, ui->subscribeToolButton); /* Connect signals */ connect(ui->postButton, SIGNAL(clicked()), this, SLOT(createMsg())); connect(ui->subscribeToolButton, SIGNAL(subscribe(bool)), this, SLOT(subscribeGroup(bool))); connect(NotifyQt::getInstance(), SIGNAL(settingsChanged()), this, SLOT(settingsChanged())); /* add filter actions */ ui->filterLineEdit->addFilter(QIcon(), tr("Title"), FILTER_TITLE, tr("Search Title")); ui->filterLineEdit->addFilter(QIcon(), tr("Message"), FILTER_MSG, tr("Search Message")); ui->filterLineEdit->addFilter(QIcon(), tr("Filename"), FILTER_FILE_NAME, tr("Search Filename")); connect(ui->filterLineEdit, SIGNAL(textChanged(QString)), ui->feedWidget, SLOT(setFilterText(QString))); connect(ui->filterLineEdit, SIGNAL(textChanged(QString)), ui->fileWidget, SLOT(setFilterText(QString))); connect(ui->filterLineEdit, SIGNAL(filterChanged(int)), this, SLOT(filterChanged(int))); /* Initialize view button */ //setViewMode(VIEW_MODE_FEEDS); see processSettings ui->infoWidget->hide(); QSignalMapper *signalMapper = new QSignalMapper(this); connect(ui->feedToolButton, SIGNAL(clicked()), signalMapper, SLOT(map())); connect(ui->fileToolButton, SIGNAL(clicked()), signalMapper, SLOT(map())); signalMapper->setMapping(ui->feedToolButton, VIEW_MODE_FEEDS); signalMapper->setMapping(ui->fileToolButton, VIEW_MODE_FILES); connect(signalMapper, SIGNAL(mapped(int)), this, SLOT(setViewMode(int))); /*************** Setup Left Hand Side (List of Channels) ****************/ ui->loadingLabel->hide(); ui->progressBar->hide(); ui->nameLabel->setMinimumWidth(20); /* Initialize feed widget */ ui->feedWidget->setSortRole(ROLE_PUBLISH, Qt::DescendingOrder); ui->feedWidget->setFilterCallback(filterItem); /* load settings */ processSettings(true); /* Initialize subscribe button */ QIcon icon; icon.addPixmap(QPixmap(":/images/redled.png"), QIcon::Normal, QIcon::On); icon.addPixmap(QPixmap(":/images/start.png"), QIcon::Normal, QIcon::Off); mAutoDownloadAction = new QAction(icon, "", this); mAutoDownloadAction->setCheckable(true); connect(mAutoDownloadAction, SIGNAL(triggered()), this, SLOT(toggleAutoDownload())); ui->subscribeToolButton->addSubscribedAction(mAutoDownloadAction); /* Initialize GUI */ setAutoDownload(false); settingsChanged(); setGroupId(channelId); }
/** Constructor */ CreateGxsForumMsg::CreateGxsForumMsg(const RsGxsGroupId &fId, const RsGxsMessageId &pId) : QDialog(NULL, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint), mForumId(fId), mParentId(pId) { /* Invoke the Qt Designer generated object setup routine */ ui.setupUi(this); setAttribute(Qt::WA_DeleteOnClose, true); /* Setup Queue */ mForumQueue = new TokenQueue(rsGxsForums->getTokenService(), this); mCirclesQueue = new TokenQueue(rsGxsCircles->getTokenService(), this); /* Setup UI helper */ mStateHelper = new UIStateHelper(this); mStateHelper->addWidget(CREATEGXSFORUMMSG_FORUMINFO, ui.buttonBox->button(QDialogButtonBox::Ok)); mStateHelper->addWidget(CREATEGXSFORUMMSG_FORUMINFO, ui.innerFrame); mStateHelper->addLoadPlaceholder(CREATEGXSFORUMMSG_FORUMINFO, ui.forumName); mStateHelper->addLoadPlaceholder(CREATEGXSFORUMMSG_FORUMINFO, ui.forumSubject); mStateHelper->addClear(CREATEGXSFORUMMSG_FORUMINFO, ui.forumName); mStateHelper->addWidget(CREATEGXSFORUMMSG_PARENTMSG, ui.buttonBox->button(QDialogButtonBox::Ok)); mStateHelper->addWidget(CREATEGXSFORUMMSG_PARENTMSG, ui.innerFrame); mStateHelper->addLoadPlaceholder(CREATEGXSFORUMMSG_PARENTMSG, ui.forumName); mStateHelper->addLoadPlaceholder(CREATEGXSFORUMMSG_PARENTMSG, ui.forumSubject); mStateHelper->addClear(CREATEGXSFORUMMSG_PARENTMSG, ui.forumName); QString text = pId.isNull() ? tr("Start New Thread") : tr("Post Forum Message"); setWindowTitle(text); ui.headerFrame->setHeaderImage(QPixmap(":/images/konversation64.png")); ui.headerFrame->setHeaderText(text); ui.generateSpinBox->setEnabled(false); Settings->loadWidgetInformation(this); connect(ui.hashBox, SIGNAL(fileHashingFinished(QList<HashedFile>)), this, SLOT(fileHashingFinished(QList<HashedFile>))); /* Rename Ok button */ ui.buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Send")); // connect up the buttons. connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(createMsg())); connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(reject())); connect(ui.emoticonButton, SIGNAL(clicked()), this, SLOT(smileyWidgetForums())); connect(ui.attachFileButton, SIGNAL(clicked()), this, SLOT(addFile())); connect(ui.generateCheckBox, SIGNAL(toggled(bool)), ui.generateSpinBox, SLOT(setEnabled(bool))); setAcceptDrops(true); ui.hashBox->setDropWidget(this); ui.hashBox->setAutoHide(false); mParentMsgLoaded = false; mForumMetaLoaded = false; mForumCircleLoaded = false; newMsg(); #ifndef ENABLE_GENERATE ui.generateCheckBox->hide(); ui.generateSpinBox->hide(); #endif }
void kbdintr(void) { uint ch; ch = inb(0x64); if((ch & 0x01) == 0) { //cprintf("no data\n"); return; } ch = inb(0x60); //press down if((ch & 0x80) == 0) { //flag int flag_temp; flag_temp = shiftcode[ch]; if(flag_temp != NO) { flag_shift = flag_temp; return; } //caps lock if(togglecode[ch] == CAPSLOCK) { //cprintf("caps\n"); flag_caps = 1; return; } //get result char result; if(flag_caps == 0) { switch(flag_shift) { case SHIFT: result = shiftmap[ch]; break; case CTL: result = ctlmap[ch]; break; default: result = normalmap[ch]; break; } } else { switch(flag_shift) { case SHIFT: result = normalmap[ch]; break; case CTL: result = ctlmap[ch]; break; default: result = shiftmap[ch]; break; } } createMsg(MSG_KEYDOWN, 0, 0, result); //cprintf("ch: %d\n", ch); // if(ch == 1) // flag = KBD_ESC; // else if(ch == 75) // flag = KBD_LEFT; // else if(ch == 77) // flag = KBD_RIGHT; // else if(ch == 72) // flag = KBD_UP; // else if(ch == 80) // flag = KBD_DOWN; // else // flag = 0; // int cur_icon = WindowLine->next->Cur_icon; // if(cur_icon == ICON_TEXT) // { // kbd_text(result, flag); // } // else if(cur_icon == ICON_PHOTO) // photo(result, flag); } //release else { ch = ch & 0x7F; //caps lock if(togglecode[ch] == CAPSLOCK) { //cprintf("caps\n"); flag_caps = 0; } //shift if(shiftcode[ch] == flag_shift) { //cprintf("shift\n"); flag_shift = NO; } return; } }
int main(int argc, char **argv) { int permission = 0644; int opt; size_t size = 0; int nsems = 0; int doShm = 0, doMsg = 0, doSem = 0; progname = program_invocation_short_name; if (!progname) progname = "ipcmk"; setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); while((opt = getopt(argc, argv, "hM:QS:p:")) != -1) { switch(opt) { case 'M': size = atoi(optarg); doShm = 1; break; case 'Q': doMsg = 1; break; case 'S': nsems = atoi(optarg); doSem = 1; break; case 'p': permission = strtoul(optarg, NULL, 8); break; case 'h': usage(EXIT_SUCCESS); break; default: doShm = doMsg = doSem = 0; break; } } if(!doShm && !doMsg && !doSem) usage(EXIT_FAILURE); if (doShm) { int shmid; if (-1 == (shmid = createShm(size, permission))) err(EXIT_FAILURE, _("create share memory failed")); else printf(_("Shared memory id: %d\n"), shmid); } if (doMsg) { int msgid; if (-1 == (msgid = createMsg(permission))) err(EXIT_FAILURE, _("create message queue failed")); else printf(_("Message queue id: %d\n"), msgid); } if (doSem) { int semid; if (-1 == (semid = createSem(nsems, permission))) err(EXIT_FAILURE, _("create semaphore failed")); else printf(_("Semaphore id: %d\n"), semid); } return EXIT_SUCCESS; }
void obp_uds(void *pvParameters) { //>>>> oobdtemple protocol initmain >>>> int keeprunning = 1; data_packet *dp; data_packet actDataPacket; UBaseType_t busToUse = *(UBaseType_t *) pvParameters; /* function pointers to the bus interface */ extern bus_init actBus_init; extern bus_send actBus_send; extern bus_flush actBus_flush; extern bus_param actBus_param; extern bus_close actBus_close; extern QueueHandle_t protocolQueue; extern QueueHandle_t outputQueue; extern QueueHandle_t inputQueue; MsgData *msg; MsgData *ownMsg; param_data *args; extern SemaphoreHandle_t protocollBinarySemaphore; UBaseType_t msgType; UBaseType_t timeout = 0; UBaseType_t showBusTransfer = 0; int i; //catch the "Protocoll is running" Semaphore xSemaphoreTake(protocollBinarySemaphore, portMAX_DELAY); DEBUGPRINT("Start Bus nr %ld\n", busToUse); /* activate the bus... */ odbarr[busToUse] (); actBus_init(); ODPBuffer *protocolBuffer; protocolBuffer = NULL; // start with the protocol specific initalisation //<<<< oobdtemple protocol initmain <<<< extern print_cbf printdata_CAN; UBaseType_t sequenceCounter; UBaseType_t remainingBytes; UBaseType_t actBufferPos; UBaseType_t actFrameLen; UBaseType_t separationTime_ST = 0; UBaseType_t actBlockSize_BS = 0; UBaseType_t actSeparationTime_STTicks = 0; UBaseType_t stateMachine_state = 0; unsigned char telegram[8]; struct TPElement *tpList = NULL; //!< keeps the list of testerPresents /* tell the Rx-ISR about the function to use for received data */ busControl(ODB_CMD_RECV, odp_uds_recvdata); protocolBuffer = createODPBuffer(UDSSIZE); if (protocolBuffer == NULL) { keeprunning = 0; } else { protocolBuffer->len = 0; } extern protocolConfigPtr actProtConfigPtr; struct UdsConfig *protocolConfig; protocolConfig = pvPortMalloc(sizeof(struct UdsConfig)); if (protocolConfig == NULL) { keeprunning = 0; } else { actProtConfigPtr = protocolConfig; /* Init default parameters */ protocolConfig->recvID = 0x7DF; protocolConfig->sendID = 0x00; // 0 disables special sendID protocolConfig->timeout = 6; protocolConfig->timeoutPending = 150; protocolConfig->blockSize = 0; protocolConfig->separationTime = 0; protocolConfig->tpFreq = 250; protocolConfig->tpType = 0x80; } //>>>> oobdtemple protocol mainloop_start >>>> for (; keeprunning;) { if (MSG_NONE != (msgType = waitMsg(protocolQueue, &msg, portMAX_DELAY))) // portMAX_DELAY /* handle message */ { switch (msgType) { //<<<< oobdtemple protocol mainloop_start <<<< //>>>> oobdtemple protocol MSG_BUS_RECV >>>> case MSG_BUS_RECV: dp = msg->addr; //<<<< oobdtemple protocol MSG_BUS_RECV <<<< if (showBusTransfer > 0) { odp_uds_dumpFrame(dp, printdata_CAN); } if (((protocolConfig->sendID == 0 ? dp->recv == (protocolConfig->recvID | 8) : dp->recv == protocolConfig->sendID)) || protocolConfig->recvID == 0x7DF) { /* Tester Address correct / we sendes a broadcast (protocolConfig->recvID==0x7DF)? */ if (dp->data[0] == 0x03 && dp->data[1] == 0x7f && dp->data[3] == 0x78) //Response pending { timeout = protocolConfig->timeoutPending; } else { if (stateMachine_state == SM_UDS_WAIT_FOR_FC) { if ((dp->data[0] & 0xF0) == 0x30) { /* FlowControl */ DEBUGPRINT("FlowControl received\n", 'a'); /* as we now probably have to send many frames first before we receive any new answer from the module, we have to disable the timeout as long as we've sent the last frame */ timeout = 0; //! \todo how to correctly support "wait" if LowNibble of PCI is 1? if (protocolConfig->blockSize == 0) { actBlockSize_BS = dp->data[1]; /* take the block size out of the FC block */ } else { actBlockSize_BS = protocolConfig->blockSize; /* use the config value instead the one from FC */ } if (actBlockSize_BS > 0) { actBlockSize_BS++; DEBUGPRINT ("Blocksize received with %ld ticks\n", actBlockSize_BS); } if (protocolConfig->separationTime == 0) { separationTime_ST = dp->data[2]; /* take the separation time out of the FC block */ } else { separationTime_ST = protocolConfig->separationTime; /* use the config value instead the one from FC */ } if (separationTime_ST > 0) { stateMachine_state = SM_UDS_SLEEP_UNTIL_SINGLE_CF; actSeparationTime_STTicks = separationTime_ST / portTICK_PERIOD_MS; actSeparationTime_STTicks++; if (actSeparationTime_STTicks < 2) { actSeparationTime_STTicks = 2; } DEBUGPRINT ("FlowControl Delay received with %d ticks\n", actSeparationTime_STTicks); } else { stateMachine_state = SM_UDS_SEND_CF; } } else { /* wrong answer */ stateMachine_state = SM_UDS_STANDBY; protocolBuffer->len = 0; createCommandResultMsg (FBID_PROTOCOL_GENERIC, ERR_CODE_UDS_MISSING_FLOW_CONTROL, (dp->data[0] & 0xF0), ERR_CODE_UDS_MISSING_FLOW_CONTROL_TEXT); } } if (stateMachine_state == SM_UDS_SEND_CF) { /* Caution: This "if state" needs to be straight after the Flow Control handling above, so that when the state SM_UDS_SEND_CF is reached, the state machine starts straight to send */ //! \todo delayed, block wise sending of Consecutive frame still needs to be implemented while (remainingBytes > 0) { DEBUGPRINT("Remaining bytes: %ld\n", remainingBytes); actFrameLen = remainingBytes > 7 ? 7 : remainingBytes; odp_uds_data2CAN(&protocolBuffer->data [actBufferPos], &telegram[0], actFrameLen, 1); sequenceCounter = sequenceCounter < 15 ? sequenceCounter + 1 : 0; actBufferPos += actFrameLen; remainingBytes -= actFrameLen; actDataPacket.data[0] = 0x20 + sequenceCounter; // prepare CF if (showBusTransfer > 0) { odp_uds_dumpFrame(&actDataPacket, printdata_CAN); } actBus_send(&actDataPacket); } stateMachine_state = SM_UDS_WAIT_FOR_ANSWER; timeout = protocolConfig->timeout; } if (stateMachine_state == SM_UDS_WAIT_FOR_CF) { if ((dp->data[0] & 0xF0) == 0x20) { /* consecutive Frame */ DEBUGPRINT ("Consecutive Frame seq. %ld\n", sequenceCounter); sequenceCounter = sequenceCounter > 14 ? 0 : sequenceCounter + 1; if ((dp->data[0] & 0x0F) == sequenceCounter) { DEBUGPRINT("Sequence ok seq. %ld\n", sequenceCounter); actFrameLen = remainingBytes > 7 ? 7 : remainingBytes; udp_uds_CAN2data(protocolBuffer, &(dp->data[1]), actBufferPos, actFrameLen); actBufferPos += actFrameLen; remainingBytes -= actFrameLen; timeout = protocolConfig->timeout; DEBUGPRINT ("actualBufferPos %ld remaining Bytes %ld\n", actBufferPos, remainingBytes); if (remainingBytes == 0) { /* finished */ stateMachine_state = SM_UDS_STANDBY; timeout = 0; /* to dump the buffer, we send the address of the udsbuffer to the print routine */ ownMsg = createMsg(&protocolBuffer, 0); /* add correct print routine; */ ownMsg->print = odp_uds_printdata_Buffer; // send event information to the ILM task CreateEventMsg (MSG_EVENT_PROTOCOL_RECEIVED, 0); /* forward data to the output task */ if (pdPASS != sendMsg(MSG_DUMP_BUFFER, outputQueue, ownMsg)) { DEBUGPRINT ("FATAL ERROR: output queue is full!\n", 'a'); } } } else { /* sequence error! */ stateMachine_state = SM_UDS_STANDBY; createCommandResultMsg (FBID_PROTOCOL_GENERIC, ERR_CODE_UDS_WRONG_SEQUENCE_COUNT, (dp->data[0] & 0x0F), ERR_CODE_UDS_WRONG_SEQUENCE_COUNT_TEXT); DEBUGPRINT ("Sequence Error! Received %d , expected %ld\n", dp->data[0] & 0x0F, sequenceCounter); timeout = 0; if (pdPASS != sendMsg(MSG_SERIAL_RELEASE, inputQueue, NULL)) { DEBUGPRINT ("FATAL ERROR: input queue is full!\n", 'a'); } } } else { stateMachine_state = SM_UDS_STANDBY; createCommandResultMsg (FBID_PROTOCOL_GENERIC, ERR_CODE_UDS_MISSING_FIRST_FRAME, (dp->data[0] & 0xF0), ERR_CODE_UDS_MISSING_FIRST_FRAME_TEXT); DEBUGPRINT ("Wrong Frame Error! Received %d , expected 0x2x\n", dp->data[0]); timeout = 0; if (pdPASS != sendMsg(MSG_SERIAL_RELEASE, inputQueue, NULL)) { DEBUGPRINT ("FATAL ERROR: input queue is full!\n", 'a'); } } } if (stateMachine_state == SM_UDS_WAIT_FOR_ANSWER) { if ((dp->data[0] & 0xF0) == 0x10) { /* FirstFrame */ sequenceCounter = 0; //first Frame counts as sequence 0 already remainingBytes = (dp->data[0] & 0xF) * 256 + dp->data[1]; actBufferPos = 6; DEBUGPRINT("First Frame with %ld Bytes\n", remainingBytes); protocolBuffer->len = remainingBytes; /* set the buffer size alredy inhope, that all goes well ;-) */ remainingBytes -= 6; /* the first 6 bytes are already in the FF */ udp_uds_CAN2data(protocolBuffer, &(dp->data[2]), 0, 6); actDataPacket.recv = protocolConfig->recvID; actDataPacket.data = &telegram[0]; actDataPacket.len = 8; for (i = 0; i < 8; i++) { /* just fill the telegram with 0 */ telegram[i] = 0; } telegram[0] = 0x30; /* 0x30 = 3=>FlowControl, 0=>CTS = ContinoueToSend */ stateMachine_state = SM_UDS_WAIT_FOR_CF; timeout = protocolConfig->timeout; if (showBusTransfer > 0) { odp_uds_dumpFrame(&actDataPacket, printdata_CAN); } actBus_send(&actDataPacket); } else { if ((dp->data[0] & 0xF0) == 0x00) { /*Single Frame */ DEBUGPRINT ("Single Frame with %d Bytes\n", dp->data[0]); protocolBuffer->len = dp->data[0]; udp_uds_CAN2data(protocolBuffer, &(dp->data[1]), 0, dp->data[0]); stateMachine_state = SM_UDS_STANDBY; timeout = 0; /* to dump the buffer, we send the address of the udsbuffer to the print routine */ ownMsg = createMsg(&protocolBuffer, sizeof(protocolBuffer)); /* add correct print routine; */ ownMsg->print = odp_uds_printdata_Buffer; // send event information to the ILM task CreateEventMsg (MSG_EVENT_PROTOCOL_RECEIVED, 0); /* forward data to the output task */ if (pdPASS != sendMsg(MSG_DUMP_BUFFER, outputQueue, ownMsg)) { DEBUGPRINT ("FATAL ERROR: output queue is full!\n", 'a'); } } } } } } //>>>> oobdtemple protocol MSG_SERIAL_DATA >>>> break; case MSG_SERIAL_DATA: if (stateMachine_state == SM_UDS_STANDBY) { /* only if just nothing to do */ dp = (data_packet *) msg->addr; // data block received from serial input which need to be handled now //<<<< oobdtemple protocol MSG_SERIAL_DATA <<<< if (((protocolBuffer->len) + dp->len) <= UDSSIZE) { /* copy the data into the uds- buffer */ for (i = 0; i < dp->len; i++) { protocolBuffer->data[protocolBuffer->len++] = dp->data[i]; } } else { createCommandResultMsg(FBID_PROTOCOL_GENERIC, ERR_CODE_UDS_DATA_TOO_LONG_ERR, (protocolBuffer->len) + dp->len, ERR_CODE_UDS_DATA_TOO_LONG_ERR_TEXT); } } //>>>> oobdtemple protocol MSG_SERIAL_PARAM_1 >>>> break; case MSG_SERIAL_PARAM: args = (UBaseType_t *) msg->addr; DEBUGPRINT("protocol parameter received %ld %ld %ld\n", args->args[ARG_RECV], args->args[ARG_CMD], args->args[ARG_VALUE_1]); switch (args->args[ARG_RECV]) { case FBID_PROTOCOL_GENERIC: DEBUGPRINT ("generic protocol parameter received %ld %ld\n", args->args[ARG_CMD], args->args[ARG_VALUE_1]); switch (args->args[ARG_CMD]) { case PARAM_INFO: //<<<< oobdtemple protocol MSG_SERIAL_PARAM_1 <<<< CreateParamOutputMsg(args, odp_uds_printParam); //>>>> oobdtemple protocol MSG_SERIAL_PARAM_2 >>>> break; // and here we proceed all command parameters case PARAM_LISTEN: showBusTransfer = args->args[ARG_VALUE_1]; createCommandResultMsg(FBID_PROTOCOL_GENERIC, ERR_CODE_NO_ERR, 0, NULL); break; default: createCommandResultMsg(FBID_PROTOCOL_GENERIC, ERR_CODE_OS_UNKNOWN_COMMAND, 0, ERR_CODE_OS_UNKNOWN_COMMAND_TEXT); break; } break; //<<<< oobdtemple protocol MSG_SERIAL_PARAM_2 <<<< case FBID_PROTOCOL_SPEC: DEBUGPRINT("uds protocol parameter received %ld %ld\n", args->args[ARG_CMD], args->args[ARG_VALUE_1]); switch (args->args[ARG_CMD]) { // first we commend out all parameters which are not used to generate the right "unknown parameter" message in the default - area /* case PARAM_ECHO: break; case PARAM_TIMEOUT_PENDING: break; case PARAM_BLOCKSIZE: break; case PARAM_FRAME_DELAY: break; */ case PARAM_TIMEOUT: protocolConfig->timeout = args->args[ARG_VALUE_1] + 1; createCommandResultMsg(FBID_PROTOCOL_SPEC, ERR_CODE_NO_ERR, 0, NULL); break; case PARAM_RECVID: protocolConfig->recvID = args->args[ARG_VALUE_1]; createCommandResultMsg(FBID_PROTOCOL_SPEC, ERR_CODE_NO_ERR, 0, NULL); break; case PARAM_SENDID: protocolConfig->sendID = args->args[ARG_VALUE_1]; createCommandResultMsg(FBID_PROTOCOL_SPEC, ERR_CODE_NO_ERR, 0, NULL); break; case PARAM_TP_ON: if (odp_uds_addTesterPresents(&tpList, args->args [ARG_VALUE_1], protocolConfig-> tpFreq, protocolConfig-> tpType)) { createCommandResultMsg(FBID_PROTOCOL_SPEC, ERR_CODE_NO_ERR, 0, NULL); } else { createCommandResultMsg(FBID_PROTOCOL_SPEC, ERR_CODE_UDS_TP_OOM, 0, ERR_CODE_UDS_TP_OOM_TEXT); } break; case PARAM_TP_OFF: odp_uds_deleteTesterPresents(&tpList, args->args [ARG_VALUE_1]); createCommandResultMsg(FBID_PROTOCOL_SPEC, ERR_CODE_NO_ERR, 0, NULL); break; case PARAM_TP_TYPE: protocolConfig->tpType = args->args[ARG_VALUE_1]; createCommandResultMsg(FBID_PROTOCOL_SPEC, ERR_CODE_NO_ERR, 0, NULL); break; case PARAM_TP_FREQ: protocolConfig->tpFreq = args->args[ARG_VALUE_1]; createCommandResultMsg(FBID_PROTOCOL_SPEC, ERR_CODE_NO_ERR, 0, NULL); break; createCommandResultMsg(FBID_PROTOCOL_SPEC, ERR_CODE_NO_ERR, 0, NULL); default: createCommandResultMsg(FBID_PROTOCOL_SPEC, ERR_CODE_OS_UNKNOWN_COMMAND, 0, ERR_CODE_OS_UNKNOWN_COMMAND_TEXT); break; } break; //>>>> oobdtemple protocol MSG_OTHERS >>>> case FBID_BUS_GENERIC: case FBID_BUS_SPEC: actBus_param(args); /* forward the received params to the underlying bus. */ break; default: createCommandResultMsg(FBID_PROTOCOL_SPEC, ERR_CODE_OS_UNKNOWN_COMMAND, 0, ERR_CODE_OS_UNKNOWN_COMMAND_TEXT); break; } //<<<< oobdtemple protocol MSG_OTHERS <<<< //>>>> oobdtemple protocol MSG_INIT >>>> case MSG_INIT: DEBUGPRINT("Reset Protocol\n", 'a'); if (protocolBuffer != NULL) { protocolBuffer->len = 0; } //<<<< oobdtemple protocol MSG_INIT <<<< //>>>> oobdtemple protocol MSG_PROTOCOL_STOP >>>> break; case MSG_PROTOCOL_STOP: DEBUGPRINT("Stop Protocol\n", 'a'); keeprunning = 0; break; //<<<< oobdtemple protocol MSG_PROTOCOL_STOP <<<< //>>>> oobdtemple protocol MSG_SEND_BUFFER >>>> case MSG_SEND_BUFFER: /* let's Dance: Starting the transfer protocol */ //<<<< oobdtemple protocol MSG_SEND_BUFFER <<<< if (protocolBuffer->len > 0) { actDataPacket.recv = protocolConfig->recvID; actDataPacket.data = &telegram; actDataPacket.len = 8; if (protocolBuffer->len < 8) { /* its just single frame */ odp_uds_data2CAN(&protocolBuffer->data[0], &telegram, protocolBuffer->len, 1); actDataPacket.data[0] = protocolBuffer->len; protocolBuffer->len = 0; /* prepare buffer to receive */ actBufferPos = 0; if (showBusTransfer > 0) { odp_uds_dumpFrame(&actDataPacket, printdata_CAN); } actBus_send(&actDataPacket); stateMachine_state = SM_UDS_WAIT_FOR_ANSWER; timeout = protocolConfig->timeout; } else { /* we have to send multiframes */ odp_uds_data2CAN(&protocolBuffer->data[0], &telegram, 6, 2); actDataPacket.data[0] = 0x10 + (protocolBuffer->len / 256); /* prepare FF */ actDataPacket.data[1] = protocolBuffer->len % 256; sequenceCounter = 0; remainingBytes = protocolBuffer->len - 6; actBufferPos = 6; protocolBuffer->len = 0; /* prepare buffer to receive */ if (showBusTransfer > 0) { odp_uds_dumpFrame(&actDataPacket, printdata_CAN); } actBus_send(&actDataPacket); stateMachine_state = SM_UDS_WAIT_FOR_FC; timeout = protocolConfig->timeout; } //>>>> oobdtemple protocol MSG_SEND_BUFFER_2 >>>> } else { /* no data to send? */ createCommandResultMsg (FBID_PROTOCOL_GENERIC, ERR_CODE_NO_ERR, 0, NULL); DEBUGPRINT("Send input task release msg\n", 'a'); /* just release the input again */ if (pdPASS != sendMsg(MSG_SERIAL_RELEASE, inputQueue, NULL)) { DEBUGPRINT ("FATAL ERROR: input queue is full!\n", 'a'); } } break; //<<<< oobdtemple protocol MSG_SEND_BUFFER_2 <<<< //>>>> oobdtemple protocol MSG_TICK >>>> case MSG_TICK: //<<<< oobdtemple protocol MSG_TICK <<<< if (timeout > 0) { /* we just waiting for an answer */ if (timeout == 1) { /* time's gone... */ protocolBuffer->len = 0; DEBUGPRINT("Timeout!\n", 'a'); createCommandResultMsg(FBID_PROTOCOL_GENERIC, ERR_CODE_UDS_TIMEOUT, 0, ERR_CODE_UDS_TIMEOUT_TEXT); stateMachine_state = SM_UDS_STANDBY; if (pdPASS != sendMsg(MSG_SERIAL_RELEASE, inputQueue, NULL)) { DEBUGPRINT ("FATAL ERROR: input queue is full!\n", 'a'); } } timeout--; } if (actSeparationTime_STTicks > 0) { DEBUGPRINT ("Remaining CF Waitticks: %ld , remainingBytes: %ld\n", actSeparationTime_STTicks, remainingBytes); stateMachine_state = SM_UDS_SLEEP_UNTIL_SINGLE_CF; actSeparationTime_STTicks--; if (actSeparationTime_STTicks < 1) { //it's time for a new single CF stateMachine_state = SM_UDS_SEND_SINGLE_CF; actSeparationTime_STTicks = separationTime_ST / portTICK_PERIOD_MS; //"reload" the counter actSeparationTime_STTicks++; if (actSeparationTime_STTicks < 2) { actSeparationTime_STTicks = 2; } DEBUGPRINT ("Reloaded CF Waitticks: %ld , remainingBytes: %ld\n", actSeparationTime_STTicks, remainingBytes); } } /* Start generating tester present messages */ odp_uds_generateTesterPresents(tpList, &telegram, actBus_send); //>>>> oobdtemple protocol final >>>> break; } //if (Ticker oder sonstiges Consecutife Frame){ if (1) { if (stateMachine_state == SM_UDS_SEND_CF || stateMachine_state == SM_UDS_SEND_SINGLE_CF) { while (remainingBytes > 0 && (stateMachine_state != SM_UDS_SLEEP_UNTIL_SINGLE_CF) && (actBlockSize_BS != 1)) { if (stateMachine_state == SM_UDS_SEND_SINGLE_CF) { stateMachine_state = SM_UDS_SLEEP_UNTIL_SINGLE_CF; } DEBUGPRINT("Remaining bytes: %ld\n", remainingBytes); actFrameLen = remainingBytes > 7 ? 7 : remainingBytes; odp_uds_data2CAN(&protocolBuffer->data [actBufferPos], &telegram[0], actFrameLen, 1); sequenceCounter = sequenceCounter < 15 ? sequenceCounter + 1 : 0; actBufferPos += actFrameLen; remainingBytes -= actFrameLen; actDataPacket.data[0] = 0x20 + sequenceCounter; // prepare CF if (showBusTransfer > 0) { odp_uds_dumpFrame(&actDataPacket, printdata_CAN); } actBus_send(&actDataPacket); if (actBlockSize_BS > 1) { actBlockSize_BS--; DEBUGPRINT("Blocksize REDUCED to %ld \n", actBlockSize_BS); } } if (actBlockSize_BS == 1) { //in case we had some block limitations, send them and then wait for another FC Frame stateMachine_state = SM_UDS_WAIT_FOR_FC; actBlockSize_BS = 0; timeout = protocolConfig->timeout; } if (remainingBytes < 1) { // Buffer empty? Then finish stateMachine_state = SM_UDS_WAIT_FOR_ANSWER; actSeparationTime_STTicks = 0; timeout = protocolConfig->timeout; } } } disposeMsg(msg); } /* vTaskDelay (5000 / portTICK_PERIOD_MS); */ } /* Do all cleanup here to finish task */ actBus_close(); vPortFree(protocolConfig); freeODPBuffer(protocolBuffer); odp_uds_freeTPBuffers(tpList); xSemaphoreGive(protocollBinarySemaphore); vTaskDelete(NULL); }
void ChannelFeed::channelListCustomPopupMenu( QPoint /*point*/ ) { ChannelInfo ci; if (!rsChannels->getChannelInfo(mChannelId, ci)) { return; } QMenu contextMnu(this); QAction *postchannelAct = new QAction(QIcon(":/images/mail_reply.png"), tr( "Post to Channel" ), &contextMnu); connect( postchannelAct , SIGNAL( triggered() ), this, SLOT( createMsg() ) ); QAction *subscribechannelAct = new QAction(QIcon(":/images/edit_add24.png"), tr( "Subscribe to Channel" ), &contextMnu); connect( subscribechannelAct , SIGNAL( triggered() ), this, SLOT( subscribeChannel() ) ); QAction *unsubscribechannelAct = new QAction(QIcon(":/images/cancel.png"), tr( "Unsubscribe to Channel" ), &contextMnu); connect( unsubscribechannelAct , SIGNAL( triggered() ), this, SLOT( unsubscribeChannel() ) ); QAction *setallasreadchannelAct = new QAction(QIcon(":/images/message-mail-read.png"), tr( "Set all as read" ), &contextMnu); connect( setallasreadchannelAct , SIGNAL( triggered() ), this, SLOT( setAllAsReadClicked() ) ); bool autoDl = false; rsChannels->channelGetAutoDl(mChannelId, autoDl); QAction *autochannelAct = autoDl? (new QAction(QIcon(":/images/redled.png"), tr( "Disable Auto-Download" ), &contextMnu)) : (new QAction(QIcon(":/images/start.png"),tr( "Enable Auto-Download" ), &contextMnu)) ; connect( autochannelAct , SIGNAL( triggered() ), this, SLOT( toggleAutoDownload() ) ); QAction *channeldetailsAct = new QAction(QIcon(":/images/info16.png"), tr( "Show Channel Details" ), &contextMnu); connect( channeldetailsAct , SIGNAL( triggered() ), this, SLOT( showChannelDetails() ) ); QAction *restoreKeysAct = new QAction(QIcon(":/images/settings16.png"), tr("Restore Publish Rights for Channel" ), &contextMnu); connect( restoreKeysAct , SIGNAL( triggered() ), this, SLOT( restoreChannelKeys() ) ); QAction *editChannelDetailAct = new QAction(QIcon(":/images/edit_16.png"), tr("Edit Channel Details"), &contextMnu); connect( editChannelDetailAct, SIGNAL( triggered() ), this, SLOT( editChannelDetail() ) ); QAction *shareKeyAct = new QAction(QIcon(":/images/gpgp_key_generate.png"), tr("Share Channel"), &contextMnu); connect( shareKeyAct, SIGNAL( triggered() ), this, SLOT( shareKey() ) ); if((ci.channelFlags & RS_DISTRIB_ADMIN) && (ci.channelFlags & RS_DISTRIB_SUBSCRIBED)) contextMnu.addAction( editChannelDetailAct); else contextMnu.addAction( channeldetailsAct ); if((ci.channelFlags & RS_DISTRIB_PUBLISH) && (ci.channelFlags & RS_DISTRIB_SUBSCRIBED)) { contextMnu.addAction( postchannelAct ); contextMnu.addAction( shareKeyAct ); } if(ci.channelFlags & RS_DISTRIB_SUBSCRIBED) { contextMnu.addAction( unsubscribechannelAct ); contextMnu.addAction( restoreKeysAct ); contextMnu.addSeparator(); contextMnu.addAction( autochannelAct ); contextMnu.addAction( setallasreadchannelAct ); } else contextMnu.addAction( subscribechannelAct ); contextMnu.addSeparator(); QAction *action = contextMnu.addAction(QIcon(":/images/copyrslink.png"), tr("Copy RetroShare Link"), this, SLOT(copyChannelLink())); action->setEnabled(!mChannelId.empty()); #ifdef CHAN_DEBUG contextMnu.addSeparator(); action = contextMnu.addAction("Generate mass data", this, SLOT(generateMassData())); action->setEnabled (!mChannelId.empty() && (ci.channelFlags & RS_DISTRIB_PUBLISH)); #endif contextMnu.exec(QCursor::pos()); }
void GxsChannelDialog::channelListCustomPopupMenu( QPoint /*point*/ ) { if (mChannelId.empty()) { return; } uint32_t subscribeFlags = ui.treeWidget->subscribeFlags(QString::fromStdString(mChannelId)); QMenu contextMnu(this); bool isAdmin = IS_GROUP_ADMIN(subscribeFlags); bool isPublisher = IS_GROUP_PUBLISHER(subscribeFlags); bool isSubscribed = IS_GROUP_SUBSCRIBED(subscribeFlags); bool autoDownload = rsGxsChannels->getChannelAutoDownload(mChannelId); if (isPublisher) { QAction *postchannelAct = new QAction(QIcon(":/images/mail_reply.png"), tr( "Post to Channel" ), &contextMnu); connect( postchannelAct , SIGNAL( triggered() ), this, SLOT( createMsg() ) ); contextMnu.addAction( postchannelAct ); contextMnu.addSeparator(); } if (isSubscribed) { QAction *setallasreadchannelAct = new QAction(QIcon(":/images/message-mail-read.png"), tr( "Set all as read" ), &contextMnu); connect( setallasreadchannelAct , SIGNAL( triggered() ), this, SLOT( setAllAsReadClicked() ) ); contextMnu.addAction( setallasreadchannelAct ); contextMnu.addSeparator(); QAction *autoAct = new QAction(QIcon(":/images/redled.png"), tr( "Disable Auto-Download" ), &contextMnu); QAction *noautoAct = new QAction(QIcon(":/images/start.png"),tr( "Enable Auto-Download" ), &contextMnu); connect( autoAct , SIGNAL( triggered() ), this, SLOT( toggleAutoDownload() ) ); connect( noautoAct , SIGNAL( triggered() ), this, SLOT( toggleAutoDownload() ) ); contextMnu.addAction( autoAct ); contextMnu.addAction( noautoAct ); autoAct->setEnabled(autoDownload); noautoAct->setEnabled(!autoDownload); QAction *unsubscribechannelAct = new QAction(QIcon(":/images/cancel.png"), tr( "Unsubscribe to Channel" ), &contextMnu); connect( unsubscribechannelAct , SIGNAL( triggered() ), this, SLOT( unsubscribeChannel() ) ); contextMnu.addAction( unsubscribechannelAct ); } else { QAction *subscribechannelAct = new QAction(QIcon(":/images/edit_add24.png"), tr( "Subscribe to Channel" ), &contextMnu); connect( subscribechannelAct , SIGNAL( triggered() ), this, SLOT( subscribeChannel() ) ); contextMnu.addAction( subscribechannelAct ); } if (isAdmin) { QAction *editChannelDetailAct = new QAction(QIcon(":/images/edit_16.png"), tr("Edit Channel Details"), &contextMnu); connect( editChannelDetailAct, SIGNAL( triggered() ), this, SLOT( editChannelDetail() ) ); contextMnu.addAction( editChannelDetailAct); } else { QAction *channeldetailsAct = new QAction(QIcon(":/images/info16.png"), tr( "Show Channel Details" ), &contextMnu); connect( channeldetailsAct , SIGNAL( triggered() ), this, SLOT( showChannelDetails() ) ); contextMnu.addAction( channeldetailsAct ); } if (isPublisher) { QAction *restoreKeysAct = new QAction(QIcon(":/images/settings16.png"), tr("Restore Publish Rights for Channel" ), &contextMnu); connect( restoreKeysAct , SIGNAL( triggered() ), this, SLOT( restoreChannelKeys() ) ); contextMnu.addAction( restoreKeysAct ); } else { QAction *shareKeyAct = new QAction(QIcon(":/images/gpgp_key_generate.png"), tr("Share Channel"), &contextMnu); connect( shareKeyAct, SIGNAL( triggered() ), this, SLOT( shareKey() ) ); contextMnu.addAction( shareKeyAct ); } contextMnu.addSeparator(); QAction *action = contextMnu.addAction(QIcon(":/images/copyrslink.png"), tr("Copy RetroShare Link"), this, SLOT(copyChannelLink())); action->setEnabled(!mChannelId.empty()); contextMnu.exec(QCursor::pos()); #if 0 ChannelInfo ci; if (!rsChannels->getChannelInfo(mChannelId, ci)) { return; } QMenu contextMnu(this); QAction *postchannelAct = new QAction(QIcon(":/images/mail_reply.png"), tr( "Post to Channel" ), &contextMnu); connect( postchannelAct , SIGNAL( triggered() ), this, SLOT( createMsg() ) ); QAction *subscribechannelAct = new QAction(QIcon(":/images/edit_add24.png"), tr( "Subscribe to Channel" ), &contextMnu); connect( subscribechannelAct , SIGNAL( triggered() ), this, SLOT( subscribeChannel() ) ); QAction *unsubscribechannelAct = new QAction(QIcon(":/images/cancel.png"), tr( "Unsubscribe to Channel" ), &contextMnu); connect( unsubscribechannelAct , SIGNAL( triggered() ), this, SLOT( unsubscribeChannel() ) ); QAction *setallasreadchannelAct = new QAction(QIcon(":/images/message-mail-read.png"), tr( "Set all as read" ), &contextMnu); connect( setallasreadchannelAct , SIGNAL( triggered() ), this, SLOT( setAllAsReadClicked() ) ); bool autoDl = false; rsChannels->channelGetAutoDl(mChannelId, autoDl); QAction *autochannelAct = autoDl? (new QAction(QIcon(":/images/redled.png"), tr( "Disable Auto-Download" ), &contextMnu)) : (new QAction(QIcon(":/images/start.png"),tr( "Enable Auto-Download" ), &contextMnu)) ; connect( autochannelAct , SIGNAL( triggered() ), this, SLOT( toggleAutoDownload() ) ); QAction *channeldetailsAct = new QAction(QIcon(":/images/info16.png"), tr( "Show Channel Details" ), &contextMnu); connect( channeldetailsAct , SIGNAL( triggered() ), this, SLOT( showChannelDetails() ) ); QAction *restoreKeysAct = new QAction(QIcon(":/images/settings16.png"), tr("Restore Publish Rights for Channel" ), &contextMnu); connect( restoreKeysAct , SIGNAL( triggered() ), this, SLOT( restoreChannelKeys() ) ); QAction *editChannelDetailAct = new QAction(QIcon(":/images/edit_16.png"), tr("Edit Channel Details"), &contextMnu); connect( editChannelDetailAct, SIGNAL( triggered() ), this, SLOT( editChannelDetail() ) ); QAction *shareKeyAct = new QAction(QIcon(":/images/gpgp_key_generate.png"), tr("Share Channel"), &contextMnu); connect( shareKeyAct, SIGNAL( triggered() ), this, SLOT( shareKey() ) ); if((ci.channelFlags & RS_DISTRIB_ADMIN) && (ci.channelFlags & RS_DISTRIB_SUBSCRIBED)) contextMnu.addAction( editChannelDetailAct); else contextMnu.addAction( channeldetailsAct ); if((ci.channelFlags & RS_DISTRIB_PUBLISH) && (ci.channelFlags & RS_DISTRIB_SUBSCRIBED)) { contextMnu.addAction( postchannelAct ); contextMnu.addAction( shareKeyAct ); } if(ci.channelFlags & RS_DISTRIB_SUBSCRIBED) { contextMnu.addAction( unsubscribechannelAct ); contextMnu.addAction( restoreKeysAct ); contextMnu.addSeparator(); contextMnu.addAction( autochannelAct ); contextMnu.addAction( setallasreadchannelAct ); } else contextMnu.addAction( subscribechannelAct ); contextMnu.addSeparator(); QAction *action = contextMnu.addAction(QIcon(":/images/copyrslink.png"), tr("Copy RetroShare Link"), this, SLOT(copyChannelLink())); action->setEnabled(!mChannelId.empty()); contextMnu.exec(QCursor::pos()); #endif }
/** Constructor */ BlogsDialog::BlogsDialog(QWidget *parent) : MainPage (parent) { /* Invoke the Qt Designer generated object setup routine */ setupUi(this); connect(actionCreate_Blog, SIGNAL(triggered()), this, SLOT(createBlog())); connect(postButton, SIGNAL(clicked()), this, SLOT(createMsg())); connect(subscribeButton, SIGNAL( clicked( void ) ), this, SLOT( subscribeBlog ( void ) ) ); connect(unsubscribeButton, SIGNAL( clicked( void ) ), this, SLOT( unsubscribeBlog ( void ) ) ); connect(treeView, SIGNAL(clicked(const QModelIndex &)), this, SLOT(selectBlog(const QModelIndex &))); connect(treeView, SIGNAL(activated(const QModelIndex &)), this, SLOT(toggleSelection(const QModelIndex &))); connect(treeView, SIGNAL(customContextMenuRequested( QPoint ) ), this, SLOT( blogListCustomPopupMenu( QPoint ) ) ); mBlogId = ""; mPeerId = rsPeers->getOwnId(); // add your id model = new QStandardItemModel(0, 2, this); model->setHeaderData(0, Qt::Horizontal, tr("Name"), Qt::DisplayRole); model->setHeaderData(1, Qt::Horizontal, tr("ID"), Qt::DisplayRole); treeView->setModel(model); treeView->setEditTriggers(QAbstractItemView::NoEditTriggers); treeView->setItemDelegate(new ChanGroupDelegate()); // hide header and id column treeView->setHeaderHidden(true); treeView->hideColumn(1); itemFont = QFont("ARIAL", 10); itemFont.setBold(true); QStandardItem *OwnBlogs = new QStandardItem(tr("My Blogs")); OwnBlogs->setForeground(QBrush(QColor(79, 79, 79))); OwnBlogs->setFont(itemFont); QStandardItem *SubscribedBlogs = new QStandardItem(tr("Subscribed Blogs")); SubscribedBlogs->setForeground(QBrush(QColor(79, 79, 79))); SubscribedBlogs->setFont(itemFont); QStandardItem *PopularBlogs = new QStandardItem(tr("Popular Blogs")); PopularBlogs->setForeground(QBrush(QColor(79, 79, 79))); PopularBlogs->setFont(itemFont); QStandardItem *OtherBlogs = new QStandardItem(tr("Other Blogs")); OtherBlogs->setForeground(QBrush(QColor(79, 79, 79))); OtherBlogs->setFont(itemFont); model->appendRow(OwnBlogs); model->appendRow(SubscribedBlogs); model->appendRow(PopularBlogs); model->appendRow(OtherBlogs); //added from ahead updateBlogList(); mBlogFont = QFont("MS SANS SERIF", 22); nameLabel->setFont(mBlogFont); nameLabel->setMinimumWidth(20); QMenu *blogmenu = new QMenu(); blogmenu->addAction(actionCreate_Blog); blogmenu->addSeparator(); blogpushButton->setMenu(blogmenu); QTimer *timer = new QTimer(this); timer->connect(timer, SIGNAL(timeout()), this, SLOT(checkUpdate())); timer->start(1000); }
int createLog(char *fn) { logID = createRandomNum(); stepNum = 0; ////////////////STARTUP from U//////////////// //create first message //INIT values char *x = "aaaaaaaaaaaaa"; char *hashX = hash(x); _hashChain = (char *)malloc(20+1); // the initial hash chain memset(_hashChain, 'a', 20+1); _logAuthKey = intToStr(createRandomNum()); //A A0 = _logAuthKey; char *msgAuthCode; //Z //_sessionKey = createFirstKey(); //K _sessionKey = createKey(LOG_INIT, _logAuthKey); //create msg for T struct Msg *msg = createMsg(stepNum, ID_UNTRUSTED, PUB_KEY_T, PRIV_KEY_U, _sessionKey, x); //create first log entry char *data = logToStr(createLogEntry(LOG_INIT, logID, msg)); //char *data = logToStr2(createLogEntry(LOG_INIT, logID, msg)); char *encData = encryptData(data, _sessionKey, strlen(data)); _hashChain = createY(_hashChain, encData, LOG_INIT); msgAuthCode = genMAC(_logAuthKey, _hashChain); struct ALogEntry *firstLog = createALogEntry(LOG_INIT, encData, _hashChain, msgAuthCode); writeAEntry(firstLog, fn); //////////////END STARTUP from U//////////////// /////////////RECIEVE T////////////// //verify the message int result = verifyMsg(msg, PRIV_KEY_T, PUB_KEY_U); //printf("Result from T:%d\n", result); //TODO: check valid certificate //increment protocol step ID; int p = msg->p + 1; //create X1 char *x0 = getX(msg, PRIV_KEY_T, PUB_KEY_U); char *x1 = "ZZZ"; //create session key char *sessionKeyT = createKey(RESP_MSG, _logAuthKey); //create msg struct Msg *msg1 = createMsg(p, ID_TRUSTED, PUB_KEY_U, PRIV_KEY_T, sessionKeyT, x1); /////////////END RECIEVE T////////////// /////////////FINALIZE INIT U/////////////////// //verify the msg result = verifyMsg(msg1, PRIV_KEY_U, PUB_KEY_T); //printf("Result from U:%d\n", result); //get the data data = logToStr(createLogEntry(RESP_MSG, logID, msg1)); //update hash chains and keys _logAuthKey = hash(_logAuthKey); //A+1 = H(A) _sessionKey = createKey(NORMAL_MSG, _logAuthKey); //K encData = encryptData(data, _sessionKey, strlen(data)); //MSG Authentication _hashChain = createY(_hashChain, encData, RESP_MSG); //Y+1 = H(y, encData, logtype) msgAuthCode = genMAC(_logAuthKey, _hashChain); //Z = MAC(Y) struct ALogEntry *secondLog = createALogEntry(RESP_MSG, encData, _hashChain, msgAuthCode); writeAEntry(secondLog, fn); }