void samplePointsWithOtherReference(Flower *flower, MetaSequence *metaSequence, const char *eventString, const char *otherEventString, int64_t sampleNumber, int64_t *correct, int64_t *aligned, int64_t *samples, int64_t bucketNumber, double bucketSize, stSortedSet *sortedSegments, bool duplication, double proportionOfSequence) { if(metaSequence_getLength(metaSequence) <= 1) { return; } for (int64_t i = 0; i < sampleNumber; i++) { int64_t x, y; pickAPairOfPointsP(metaSequence, &x, &y, proportionOfSequence); int64_t diff = y - x; assert(diff >= 1); int64_t bucket = log10(diff) * bucketSize; //st_uglyf("I have %" PRIi64 " %f %" PRIi64 " %" PRIi64 "\n", (int64_t)diff, bucketSize, bucket, bucketNumber); assert(bucket < bucketNumber); assert(bucket >= 0); samples[bucket]++; Segment *segmentX = getSegment(sortedSegments, x, metaSequence); if (segmentX != NULL && (duplication || !duplicated(segmentX))) { Segment *segmentY = getSegment(sortedSegments, y, metaSequence); if (segmentY != NULL && (duplication || !duplicated(segmentX))) { bool b; linked(segmentX, segmentY, diff, otherEventString, &b); if(b) { if(linked(segmentX, segmentY, diff, eventString, &b)) { correct[bucket]++; } if(b) { aligned[bucket]++; } } } } } }
int compsize(int *t, int n) { int size = 0; int i = -1; while (++i <= n){ size += linked(t, n, i); i += linked(t, n, i); } return (size); }
void O1Beatport::onLinkingSucceeded() { // This slot is used both at the end of link() and unlink() methods if(linked() && _status != Linked) { _status = Linked; } else if(!linked() && _status != Notlinked) { _status = Notlinked; } else { return; } emit statusChanged(_status); }
void Program::link() { if (!linked()) { glLinkProgram(m_id); if (linked()) { logProgramInfoLog(); GPX_NOTE("program (id: " << m_id << ") linked successfully"); } else { logProgramInfoLog(); GPX_FATAL("program (id: " << m_id << ") can not be linked"); } } else GPX_WARN("program (id: " << m_id << ") already linked"); }
bool TextEditorRemoteNode::deinitialise() { disconnect( mPinOutputText->qobject(), SIGNAL(linked(QSharedPointer<fugio::PinInterface>)), this, SLOT(textLinked(QSharedPointer<fugio::PinInterface>)) ); disconnect( mPinOutputText->qobject(), SIGNAL(unlinked(QSharedPointer<fugio::PinInterface>)), this, SLOT(textUninked(QSharedPointer<fugio::PinInterface>)) ); return( NodeControlBase::deinitialise() ); }
void SubjectCanvas::menu(const QPoint&) { Q3PopupMenu m(0); MenuFactory::createTitle(m, TR("Subject")); m.insertSeparator(); m.insertItem(TR("Upper"), 0); m.insertItem(TR("Lower"), 1); m.insertItem(TR("Go up"), 6); m.insertItem(TR("Go down"), 7); m.insertSeparator(); m.insertItem(TR("Edit"), 2); m.insertSeparator(); m.insertItem(TR("Edit drawing settings"), 3); if (linked()) { m.insertSeparator(); m.insertItem(TR("Select linked items"), 4); } m.insertSeparator(); m.insertItem(TR("Remove from diagram"),5); int index = m.exec(QCursor::pos()); switch (index) { case 0: upper(); modified(); // call package_modified() return; case 1: lower(); modified(); // call package_modified() return; case 6: z_up(); modified(); // call package_modified() return; case 7: z_down(); modified(); // call package_modified() return; case 2: open(); // modified then package_modified already called return; case 3: edit_drawing_settings(); return; case 4: the_canvas()->unselect_all(); select_associated(); return; case 5: delete_it(); break; default: return; } package_modified(); }
bool linked(value_type source, iterator target) const { iterator source_iter = std::find(begin(), end(), source); if (source_iter == end()) return false; return linked(source_iter, target); }
bool linked(iterator source, value_type target) const { iterator target_iter = std::find(begin(), end(), target); if (target_iter == end()) return false; return linked(source, target_iter); }
PGL_USING_NAMESPACE TOOLS_USING_NAMESPACE /* ----------------------------------------------------------------------- */ ViewCameraMenu::ViewCameraMenu(ViewCameraGL * camera,QWidget * parent, const char * name): QMenu(parent) { if(name)setObjectName(name); QPixmap home(ViewerIcon::getPixmap(ViewerIcon::home)); QPixmap read(ViewerIcon::getPixmap(ViewerIcon::fileopen)); QPixmap save(ViewerIcon::getPixmap(ViewerIcon::filefloppy)); QPixmap persp(ViewerIcon::getPixmap(ViewerIcon::perspective)); QPixmap ortho(ViewerIcon::getPixmap(ViewerIcon::orthographic)); QPixmap linked(ViewerIcon::getPixmap(ViewerIcon::linked)); QPixmap eyef(ViewerIcon::getPixmap(ViewerIcon::eyef)); QAction * action = addAction(home,tr("Home"), camera,SLOT(home()), Qt::CTRL+Qt::Key_I); addAction(tr("&Front View (YZ)"),camera,SLOT(YZView())); addAction(tr("&Right View (XZ)"),camera,SLOT(XZView())); addAction(tr("&Top View (XY)"), camera,SLOT(XYView())); addSeparator(); QMenu * __coordMenu = new QMenu(this); idGEOMcoord = __coordMenu->addAction(tr("GEOM System"), camera,SLOT(setGEOMCoordSys())); idGLcoord = __coordMenu->addAction(tr("GL System"), camera,SLOT(setGLCoordSys())); __coordMenu->addSeparator(); __coordMenu->addAction(tr("&Change"), camera,SLOT(changeCoordSys())); idGEOMcoord->setCheckable(true); idGLcoord->setCheckable(true); setCoordSys(camera->getCoordSys()); __coordMenu->setTitle(tr("Coordinates System")); addMenu(__coordMenu); addSeparator(); QMenu * __projectionMenu = new QMenu(this); idPerspective = __projectionMenu->addAction(persp,tr("&Perspective"), camera,SLOT(setPerspectiveMode())); idOrtho = __projectionMenu->addAction(ortho,tr("Ort&hographic"), camera,SLOT(setOrthographicMode())); __projectionMenu->addSeparator(); __projectionMenu->addAction(tr("&Change"), camera,SLOT(changeCameraMode()),Qt::CTRL+Qt::Key_D); idPerspective->setCheckable(true); idOrtho->setCheckable(true); __projectionMenu->setTitle(tr("Projection")); addMenu(__projectionMenu); setProjectionMode(camera->getProjectionMode()); QObject::connect(camera,SIGNAL(projectionChanged(bool)),this,SLOT(setProjectionMode(bool))); QObject::connect(camera,SIGNAL(coordSysChanged(int)),this,SLOT(setCoordSys(int))); addSeparator(); addAction(save,tr("&Save"), camera,SLOT(save())); addAction(read,tr("&Read"), camera,SLOT(read())); addSeparator(); QAction * idLock = addAction(linked,tr("&Auto Fit to Window"), camera,SLOT(lockDim())); if(camera)idLock->setChecked(camera->isDimLock()); QObject::connect(camera,SIGNAL(lockDimChanged(bool)),idLock,SLOT(setChecked(bool))); addAction(eyef,tr("&Fit to Window"), camera,SLOT(reDim())); }
void O1Beatport::onLinkingChanged() { if(linked()) { _status = Linked; } else { _status = Notlinked; } emit statusChanged(_status); }
void O1::unlink() { trace() << "O1::unlink"; if (linked()) { setToken(""); setTokenSecret(""); emit linkedChanged(); } emit linkingSucceeded(); }
bool TextEditorRemoteNode::initialise() { if( !NodeControlBase::initialise() ) { return( false ); } connect( mPinOutputText->qobject(), SIGNAL(linked(QSharedPointer<fugio::PinInterface>)), this, SLOT(textLinked(QSharedPointer<fugio::PinInterface>)) ); connect( mPinOutputText->qobject(), SIGNAL(unlinked(QSharedPointer<fugio::PinInterface>)), this, SLOT(textUninked(QSharedPointer<fugio::PinInterface>)) ); return( true ); }
void ImageCanvas::menu(const QPoint&) { Q3PopupMenu m(0); Q3PopupMenu fontsubm(0); MenuFactory::createTitle(m, TR("Image")); m.insertSeparator(); m.insertItem(TR("Upper"), 0); m.insertItem(TR("Lower"), 1); m.insertItem(TR("Go up"), 2); m.insertItem(TR("Go down"), 3); m.insertSeparator(); m.insertItem(TR("Edit"), 4); if (linked()) { m.insertSeparator(); m.insertItem(TR("Select linked items"), 5); } m.insertSeparator(); m.insertItem(TR("Remove from diagram"), 6); int index = m.exec(QCursor::pos()); switch (index) { case 0: upper(); modified(); // call package_modified() return; case 1: lower(); modified(); // call package_modified() return; case 2: z_up(); modified(); // call package_modified() return; case 3: z_down(); modified(); // call package_modified() return; case 4: open(); // all done by open return; case 5: the_canvas()->unselect_all(); select_associated(); return; case 6: delete_it(); break; } package_modified(); }
void JulyUrl::mouseReleaseEvent(QMouseEvent *event) { QLabel::mouseMoveEvent(event); if(event->button()==Qt::LeftButton) { setPixmap(pixmap1); if(!notPressing) { emit linked(); QDesktopServices::openUrl(QUrl("http://"+text)); notPressing=true; } } }
void GLProgram::link(State* state) { glCheck("GLProgram::link"); m_relink = false; GLint prog = 0; glRun(glGetIntegerv(GL_CURRENT_PROGRAM, &prog)); if (isLinked()) { glRun(glUseProgram(m_prog)); /// @todo Do we need this? m_uniformList = getUniformList(); } ShaderErrorList errors(state ? state->material() : MaterialPtr(), name()); if (!m_transformFeedback.isEmpty()) { const char* names[10]; int m = std::min(m_transformFeedback.size(), 10); for (int i = 0; i < m; ++i) { names[i] = m_transformFeedback[i].data(); } glRun(glTransformFeedbackVaryings(m_prog, m, names, GL_SEPARATE_ATTRIBS)); } glRun(glLinkProgram(m_prog)); GLint ok = 0; glRun(glGetProgramiv(m_prog, GL_LINK_STATUS, &ok)); GLint len = 0; glRun(glGetProgramiv(m_prog, GL_INFO_LOG_LENGTH, &len)); // len may include the zero byte if (len > 1) { std::vector<GLchar> log(len); GLsizei size = len; glRun(glGetProgramInfoLog(m_prog, size, &size, &log[0])); ShaderCompilerOutputParser::instance().parse(QString::fromUtf8(&log[0], size), errors); } if (ok) { glRun(glUseProgram(m_prog)); /// @todo Do we need this? setUniform(m_uniformList); } emit linked(errors); glRun(glUseProgram(prog)); }
TextEditorRemoteNode::TextEditorRemoteNode( QSharedPointer<fugio::NodeInterface> pNode ) : NodeControlBase( pNode ), mLastTime( 0 ) { FUGID( PIN_INPUT_PACKETS, "9e154e12-bcd8-4ead-95b1-5a59833bcf4e" ); FUGID( PIN_INPUT_TEXT, "1b5e9ce8-acb9-478d-b84b-9288ab3c42f5" ); FUGID( PIN_OUTPUT_PACKETS, "261cc653-d7fa-4c34-a08b-3603e8ae71d5" ); FUGID( PIN_OUTPUT_TEXT, "249f2932-f483-422f-b811-ab679f006381" ); mPinInputPackets = pinInput( "Packets", PIN_INPUT_PACKETS ); mValInputText = pinInput<fugio::SyntaxErrorInterface *>( "Text", mPinInputText, PID_SYNTAX_ERROR, PIN_INPUT_TEXT ); mValOutputPackets = pinOutput<fugio::VariantInterface *>( "Packets", mPinOutputPackets, PID_BYTEARRAY, PIN_OUTPUT_PACKETS ); mValOutputText = pinOutput<fugio::VariantInterface *>( "Text", mPinOutputText, PID_STRING, PIN_OUTPUT_TEXT ); connect( mPinOutputText->qobject(), SIGNAL(linked(QSharedPointer<fugio::PinInterface>)), this, SLOT(textLinked(QSharedPointer<fugio::PinInterface>)) ); connect( mPinOutputText->qobject(), SIGNAL(unlinked(QSharedPointer<fugio::PinInterface>)), this, SLOT(textUninked(QSharedPointer<fugio::PinInterface>)) ); }
int newlink(Padjlist alink) /* **-------------------------------------------------------------- ** Input: alink = element of node's adjacency list ** Output: returns 1 if successful, 0 if not ** Purpose: links end of current adjacent link to end nodes of ** all links that follow it on adjacency list **-------------------------------------------------------------- */ { int inode, jnode; Padjlist blink; /* Scan all entries in adjacency list that follow anode. */ inode = alink->node; /* End node of connection to anode */ for (blink = alink->next; blink != NULL; blink = blink->next) { jnode = blink->node; /* End node of next connection */ /* If jnode still active, and inode not connected to jnode, */ /* then add a new connection between inode and jnode. */ if (Degree[jnode] > 0) /* jnode still active */ { if (!linked(inode,jnode)) /* inode not linked to jnode */ { /* Since new connection represents a non-zero coeff. */ /* in the solution matrix, update the coeff. count. */ Ncoeffs++; /* Update adjacency lists for inode & jnode to */ /* reflect the new connection. */ if (!addlink(inode,jnode,Ncoeffs)) return(0); if (!addlink(jnode,inode,Ncoeffs)) return(0); Degree[inode]++; Degree[jnode]++; } } } return(1); } /* End of newlink */
/*Function that checks if the previous turn was a winning turn*/ int done(char n,char ***b,char *human,char *computer,int turn,int h){ int k=0; if (turn>=2*n - 1){ /* For turn<2n-1 not enough moves have been played to connect the two. edges. */ int j; char col='w'; /*Col is the color the the function looks for in the iteration(if found calls linked()). */ /*If black player played the turn just finished(would be next turn but my I use turn-1 when I call the function in main(). */ if(((!((turn+h)%2))&&((*computer)=='b'))||(((turn+h)%2)&&((*human)=='b'))){ transpose(n,b[turn]); /*Transposing the board to have the same algorithm for both black and white. */ col='b'; /*The color we're searching for is now black */ } for(j=0;j<n;j++){ if(b[turn][0][j]==col) if(linked(b[turn],n,0,j)){ /*If linked returns 1(which means it was successful) make k=1 and stop the iterations.*/ k=1; printf("\n"); break; } } /*If the board was originally transposed it returns to it's original state. */ if(((!((turn+h)%2))&&((*computer)=='b'))||(((turn+h)%2)&&((*human)=='b'))){ transpose(n,b[turn]); } } if(k){ /*Winning/losing ASCII art. */ if((turn+h)%2){ printf(" __ __ _ _ \n \\ \\ / /__ _ _ __ _(_)_ __ | |\n \\ V / _ \\| | | | \\ \\ /\\ / / | '_ \\| |\n"); printf(" | | (_) | |_| | \\ V V /| | | | |_|\n |_|\\___/ \\__,_| \\_/\\_/ |_|_| |_(_)\n"); } else{ printf(" __ __ _ _ \n \\ \\ / /__ _ _ | | ___ ___ ___| |\n \\ V / _ \\| | | | | |/ _ \\/ __|/ _ \\ |\n"); printf(" | | (_) | |_| | | | (_) \\__ \\ __/_|\n |_|\\___/ \\__,_| |_|\\___/|___/\\___(_)\n"); } } return k; }
void ActivityPartitionCanvas::menu(const QPoint&) { Q3PopupMenu m(0); Q3PopupMenu toolm(0); int index; MenuFactory::createTitle(m, browser_node->get_data()->definition(FALSE, TRUE)); m.insertSeparator(); m.insertItem(TR("Upper"), 0); m.insertItem(TR("Lower"), 1); m.insertItem(TR("Go up"), 13); m.insertItem(TR("Go down"), 14); m.insertSeparator(); m.insertItem((horiz) ? TR("draw vertically") : TR("draw horizontally"), 10); m.insertSeparator(); m.insertItem(TR("Edit drawing settings"), 2); m.insertSeparator(); m.insertItem(TR("Edit activity partition"), 3); m.insertSeparator(); m.insertItem(TR("Select in browser"), 4); if (linked()) m.insertItem(TR("Select linked items"), 5); m.insertSeparator(); if (browser_node->is_writable()) { if (browser_node->get_associated() != (BrowserNode *) the_canvas()->browser_diagram()) m.insertItem(TR("Set associated diagram"),6); if (browser_node->get_associated()) m.insertItem(TR("Remove diagram association"),9); } m.insertSeparator(); m.insertItem(TR("Remove from diagram"), 7); if (browser_node->is_writable()) m.insertItem(TR("Delete from model"), 8); m.insertSeparator(); if (Tool::menu_insert(&toolm, UmlActivityPartition, 20)) m.insertItem(TR("Tool"), &toolm); switch (index = m.exec(QCursor::pos())) { case 0: upper(); modified(); // call package_modified() return; case 1: lower(); modified(); // call package_modified() return; case 13: z_up(); modified(); // call package_modified() return; case 14: z_down(); modified(); // call package_modified() return; case 2: edit_drawing_settings(); return; case 3: browser_node->open(TRUE); return; case 4: browser_node->select_in_browser(); return; case 5: the_canvas()->unselect_all(); select_associated(); return; case 6: ((BrowserActivityPartition *) browser_node) ->set_associated_diagram((BrowserActivityDiagram *) the_canvas()->browser_diagram()); return; case 7: //remove from diagram delete_it(); break; case 8: //delete from model browser_node->delete_it(); // will delete the canvas break; case 9: ((BrowserActivityPartition *) browser_node) ->set_associated_diagram(0); return; case 10: turn(-1000, -1000); break; default: if (index >= 20) ToolCom::run(Tool::command(index - 20), browser_node); return; } package_modified(); }
void FragmentCanvas::menu(const QPoint&) { Q3PopupMenu m(0); MenuFactory::createTitle(m, TR("Fragment")); m.insertSeparator(); m.insertItem(TR("Upper"), 0); m.insertItem(TR("Lower"), 1); m.insertItem(TR("Go up"), 7); m.insertItem(TR("Go down"), 8); m.insertSeparator(); m.insertItem(TR("Edit"), 2); m.insertItem(TR("Add separator"), 6); m.insertSeparator(); m.insertItem(TR("Edit drawing settings"), 3); if (linked()) { m.insertSeparator(); m.insertItem(TR("Select linked items"), 4); } m.insertSeparator(); m.insertItem(TR("Remove from diagram"),5); if ((refer != 0) && !refer->deletedp()) { m.insertSeparator(); m.insertItem(TR("Show referenced diagram"),9); } int index = m.exec(QCursor::pos()); switch (index) { case 0: upper(); modified(); // call package_modified() return; case 1: lower(); modified(); // call package_modified() return; case 7: z_up(); modified(); // call package_modified() return; case 8: z_down(); modified(); // call package_modified() return; case 2: open(); // modified then package_modified already called return; case 3: edit_drawing_settings(); return; case 4: the_canvas()->unselect_all(); select_associated(); return; case 5: delete_it(); break; case 6: { FragmentSeparatorCanvas * sp = new FragmentSeparatorCanvas(the_canvas(), this); separators.append(sp); the_canvas()->unselect_all(); the_canvas()->select(sp); } break; case 9: refer->open(FALSE); return; default: return; } package_modified(); }
int main(int argc, char *argv[]) { struct passwd *pw; struct group *gptr; const char *arg, *cp, *printer; char *p; char buf[BUFSIZ]; int c, i, f, errs; int ret, didlink; struct stat stb; struct stat statb1, statb2; struct printer myprinter, *pp = &myprinter; printer = NULL; euid = geteuid(); uid = getuid(); PRIV_END if (signal(SIGHUP, SIG_IGN) != SIG_IGN) signal(SIGHUP, cleanup); if (signal(SIGINT, SIG_IGN) != SIG_IGN) signal(SIGINT, cleanup); if (signal(SIGQUIT, SIG_IGN) != SIG_IGN) signal(SIGQUIT, cleanup); if (signal(SIGTERM, SIG_IGN) != SIG_IGN) signal(SIGTERM, cleanup); progname = argv[0]; gethostname(local_host, sizeof(local_host)); openlog("lpd", 0, LOG_LPR); errs = 0; while ((c = getopt(argc, argv, ":#:1:2:3:4:C:J:L:P:T:U:Z:cdfghi:lnmprstvw:")) != -1) switch (c) { case '#': /* n copies */ i = strtol(optarg, &p, 10); if (*p) errx(1, "Bad argument to -#, number expected"); if (i > 0) ncopies = i; break; case '1': /* troff fonts */ case '2': case '3': case '4': fonts[optopt - '1'] = optarg; break; case 'C': /* classification spec */ hdr++; class = optarg; break; case 'J': /* job name */ hdr++; jobname = optarg; break; case 'P': /* specifiy printer name */ printer = optarg; break; case 'L': /* pr's locale */ locale = optarg; break; case 'T': /* pr's title line */ title = optarg; break; case 'U': /* user name */ hdr++; Uflag = optarg; break; case 'Z': Zflag = optarg; break; case 'c': /* print cifplot output */ case 'd': /* print tex output (dvi files) */ case 'g': /* print graph(1G) output */ case 'l': /* literal output */ case 'n': /* print ditroff output */ case 't': /* print troff output (cat files) */ case 'p': /* print using ``pr'' */ case 'v': /* print vplot output */ format = optopt; break; case 'f': /* print fortran output */ format = 'r'; break; case 'h': /* nulifiy header page */ hdr = 0; break; case 'i': /* indent output */ iflag++; indent = strtol(optarg, &p, 10); if (*p) errx(1, "Bad argument to -i, number expected"); break; case 'm': /* send mail when done */ mailflg++; break; case 'q': /* just queue job */ qflag++; break; case 'r': /* remove file when done */ rflag++; break; case 's': /* try to link files */ sflag++; break; case 'w': /* versatec page width */ width = optarg; break; case ':': /* catch "missing argument" error */ if (optopt == 'i') { iflag++; /* -i without args is valid */ indent = 8; } else errs++; break; default: errs++; } argc -= optind; argv += optind; if (errs) usage(); if (printer == NULL && (printer = getenv("PRINTER")) == NULL) printer = DEFLP; chkprinter(printer, pp); if (pp->no_copies && ncopies > 1) errx(1, "multiple copies are not allowed"); if (pp->max_copies > 0 && ncopies > pp->max_copies) errx(1, "only %ld copies are allowed", pp->max_copies); /* * Get the identity of the person doing the lpr using the same * algorithm as lprm. Actually, not quite -- lprm will override * the login name with "root" if the user is running as root; * the daemon actually checks for the string "root" in its * permission checking. Sigh. */ userid = getuid(); if (Uflag) { if (userid != 0 && userid != pp->daemon_user) errx(1, "only privileged users may use the `-U' flag"); lpr_username = Uflag; /* -U person doing 'lpr' */ } else { lpr_username = getlogin(); /* person doing 'lpr' */ if (userid != pp->daemon_user || lpr_username == 0) { if ((pw = getpwuid(userid)) == NULL) errx(1, "Who are you?"); lpr_username = pw->pw_name; } } /* * Check for restricted group access. */ if (pp->restrict_grp != NULL && userid != pp->daemon_user) { if ((gptr = getgrnam(pp->restrict_grp)) == NULL) errx(1, "Restricted group specified incorrectly"); if (gptr->gr_gid != getgid()) { while (*gptr->gr_mem != NULL) { if ((strcmp(lpr_username, *gptr->gr_mem)) == 0) break; gptr->gr_mem++; } if (*gptr->gr_mem == NULL) errx(1, "Not a member of the restricted group"); } } /* * Check to make sure queuing is enabled if userid is not root. */ lock_file_name(pp, buf, sizeof buf); if (userid && stat(buf, &stb) == 0 && (stb.st_mode & LFM_QUEUE_DIS)) errx(1, "Printer queue is disabled"); /* * Initialize the control file. */ mktemps(pp); tfd = nfile(tfname); PRIV_START (void) fchown(tfd, pp->daemon_user, -1); /* owned by daemon for protection */ PRIV_END card('H', local_host); card('P', lpr_username); card('C', class); if (hdr && !pp->no_header) { if (jobname == NULL) { if (argc == 0) jobname = "stdin"; else jobname = ((arg = strrchr(argv[0], '/')) ? arg + 1 : argv[0]); } card('J', jobname); card('L', lpr_username); } if (format != 'p' && Zflag != 0) card('Z', Zflag); if (iflag) card('I', itoa(indent)); if (mailflg) card('M', lpr_username); if (format == 't' || format == 'n' || format == 'd') for (i = 0; i < 4; i++) if (fonts[i] != NULL) card('1'+i, fonts[i]); if (width != NULL) card('W', width); /* * XXX * Our use of `Z' here is incompatible with LPRng's * use. We assume that the only use of our existing * `Z' card is as shown for `p' format (pr) files. */ if (format == 'p') { char *s; if (locale) card('Z', locale); else if ((s = setlocale(LC_TIME, "")) != NULL) card('Z', s); } /* * Read the files and spool them. */ if (argc == 0) copy(pp, 0, " "); else while (argc--) { if (argv[0][0] == '-' && argv[0][1] == '\0') { /* use stdin */ copy(pp, 0, " "); argv++; continue; } if ((f = test(arg = *argv++)) < 0) continue; /* file unreasonable */ if (sflag && (cp = linked(arg)) != NULL) { (void)snprintf(buf, sizeof(buf), "%ju %ju", (uintmax_t)statb.st_dev, (uintmax_t)statb.st_ino); card('S', buf); if (format == 'p') card('T', title ? title : arg); for (i = 0; i < ncopies; i++) card(format, &dfname[inchar-2]); card('U', &dfname[inchar-2]); if (f) card('U', cp); card('N', arg); dfname[inchar]++; nact++; continue; } if (sflag) printf("%s: %s: not linked, copying instead\n", progname, arg); if (f) { /* * The user wants the file removed after it is copied * to the spool area, so see if the file can be moved * instead of copy/unlink'ed. This is much faster and * uses less spool space than copying the file. This * can be very significant when running services like * samba, pcnfs, CAP, et al. */ PRIV_START didlink = 0; /* * There are several things to check to avoid any * security issues. Some of these are redundant * under BSD's, but are necessary when lpr is built * under some other OS's (which I do do...) */ if (lstat(arg, &statb1) < 0) goto nohardlink; if (S_ISLNK(statb1.st_mode)) goto nohardlink; if (link(arg, dfname) != 0) goto nohardlink; didlink = 1; /* * Make sure the user hasn't tried to trick us via * any race conditions */ if (lstat(dfname, &statb2) < 0) goto nohardlink; if (statb1.st_dev != statb2.st_dev) goto nohardlink; if (statb1.st_ino != statb2.st_ino) goto nohardlink; /* * Skip if the file already had multiple hard links, * because changing the owner and access-bits would * change ALL versions of the file */ if (statb2.st_nlink > 2) goto nohardlink; /* * If we can access and remove the original file * without special setuid-ness then this method is * safe. Otherwise, abandon the move and fall back * to the (usual) copy method. */ PRIV_END ret = access(dfname, R_OK); if (ret == 0) ret = unlink(arg); PRIV_START if (ret != 0) goto nohardlink; /* * Unlink of user file was successful. Change the * owner and permissions, add entries to the control * file, and skip the file copying step. */ chown(dfname, pp->daemon_user, getegid()); chmod(dfname, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP); PRIV_END if (format == 'p') card('T', title ? title : arg); for (i = 0; i < ncopies; i++) card(format, &dfname[inchar-2]); card('U', &dfname[inchar-2]); card('N', arg); nact++; continue; nohardlink: if (didlink) unlink(dfname); PRIV_END /* restore old uid */ } /* end: if (f) */ if ((i = open(arg, O_RDONLY)) < 0) { printf("%s: cannot open %s\n", progname, arg); } else { copy(pp, i, arg); (void) close(i); if (f && unlink(arg) < 0) printf("%s: %s: not removed\n", progname, arg); } } if (nact) { (void) close(tfd); tfname[inchar]--; /* * Touch the control file to fix position in the queue. */ PRIV_START if ((tfd = open(tfname, O_RDWR)) >= 0) { char touch_c; if (read(tfd, &touch_c, 1) == 1 && lseek(tfd, (off_t)0, 0) == 0 && write(tfd, &touch_c, 1) != 1) { printf("%s: cannot touch %s\n", progname, tfname); tfname[inchar]++; cleanup(0); } (void) close(tfd); } if (link(tfname, cfname) < 0) { printf("%s: cannot rename %s\n", progname, cfname); tfname[inchar]++; cleanup(0); } unlink(tfname); PRIV_END if (qflag) /* just q things up */ exit(0); if (!startdaemon(pp)) printf("jobs queued, but cannot start daemon.\n"); exit(0); } cleanup(0); return (1); /* NOTREACHED */ }
int main(int argc, char *argv[]) { struct passwd *pw; struct group *gptr; char *arg; const char *cp; char buf[MAXPATHLEN]; int i, f, errs, c; struct stat stb; int oerrno; euid = geteuid(); uid = getuid(); seteuid(uid); if (signal(SIGHUP, SIG_IGN) != SIG_IGN) signal(SIGHUP, cleanup); if (signal(SIGINT, SIG_IGN) != SIG_IGN) signal(SIGINT, cleanup); if (signal(SIGQUIT, SIG_IGN) != SIG_IGN) signal(SIGQUIT, cleanup); if (signal(SIGTERM, SIG_IGN) != SIG_IGN) signal(SIGTERM, cleanup); setprogname(*argv); gethostname(host, sizeof (host)); host[sizeof(host) - 1] = '\0'; openlog("lpd", 0, LOG_LPR); errs = 0; while ((c = getopt(argc, argv, ":#:1:2:3:4:C:J:P:RT:U:cdfghi:lmnopqrstvw:")) != -1) { switch (c) { case '#': /* n copies */ if (isdigit((unsigned char)*optarg)) { i = atoi(optarg); if (i > 0) ncopies = i; } break; case '4': /* troff fonts */ case '3': case '2': case '1': fonts[optopt - '1'] = optarg; break; case 'C': /* classification spec */ hdr++; class = optarg; break; case 'J': /* job name */ hdr++; jobname = optarg; break; case 'P': /* specifiy printer name */ printer = optarg; break; case 'R': /* print request id */ Rflag++; break; case 'T': /* pr's title line */ title = optarg; break; case 'U': /* user name */ hdr++; person = optarg; break; case 'c': /* print cifplot output */ case 'd': /* print tex output (dvi files) */ case 'g': /* print graph(1G) output */ case 'l': /* literal output */ case 'o': /* print postscript output */ case 'n': /* print ditroff output */ case 'p': /* print using ``pr'' */ case 't': /* print troff output (cat files) */ case 'v': /* print vplot output */ format = optopt; break; case 'f': /* print fortran output */ format = 'r'; break; case 'h': /* toggle want of header page */ hdr = !hdr; break; case 'i': /* indent output */ iflag++; indent = atoi(optarg); if (indent < 0) indent = 8; break; case 'm': /* send mail when done */ mailflg++; break; case 'q': /* just q job */ qflag++; break; case 'r': /* remove file when done */ rflag++; break; case 's': /* try to link files */ sflag++; break; case 'w': /* versatec page width */ width = optarg; break; case ':': /* catch "missing argument" error */ if (optopt == 'i') { iflag++; /* -i without args is valid */ indent = 8; } else errs++; break; default: errs++; } } argc -= optind; argv += optind; if (errs) usage(); if (printer == NULL && (printer = getenv("PRINTER")) == NULL) printer = DEFLP; chkprinter(printer); if (SC && ncopies > 1) errx(EXIT_FAILURE, "multiple copies are not allowed"); if (MC > 0 && ncopies > MC) errx(EXIT_FAILURE, "only %ld copies are allowed", MC); /* * Get the identity of the person doing the lpr using the same * algorithm as lprm. */ userid = getuid(); if (userid != DU || person == 0) { if ((pw = getpwuid(userid)) == NULL) errx(EXIT_FAILURE, "Who are you?"); person = pw->pw_name; } /* * Check for restricted group access. */ if (RG != NULL && userid != DU) { if ((gptr = getgrnam(RG)) == NULL) errx(EXIT_FAILURE, "Restricted group specified incorrectly"); if (gptr->gr_gid != getgid()) { while (*gptr->gr_mem != NULL) { if ((strcmp(person, *gptr->gr_mem)) == 0) break; gptr->gr_mem++; } if (*gptr->gr_mem == NULL) errx(EXIT_FAILURE, "Not a member of the restricted group"); } } /* * Check to make sure queuing is enabled if userid is not root. */ (void)snprintf(buf, sizeof buf, "%s/%s", SD, LO); if (userid && stat(buf, &stb) == 0 && (stb.st_mode & S_IXGRP)) errx(EXIT_FAILURE, "Printer queue is disabled"); /* * Initialize the control file. */ mktemps(); tfd = nfile(tfname); seteuid(euid); (void)fchown(tfd, DU, -1); /* owned by daemon for protection */ seteuid(uid); card('H', host); card('P', person); if (hdr && !SH) { if (jobname == NULL) { if (argc == 0) jobname = "stdin"; else jobname = (arg = strrchr(argv[0], '/')) ? arg+1 : argv[0]; } card('J', jobname); card('C', class); card('L', person); } if (iflag) card('I', itoa(indent)); if (mailflg) card('M', person); if (format == 't' || format == 'n' || format == 'd') for (i = 0; i < 4; i++) if (fonts[i] != NULL) card('1'+i, fonts[i]); if (width != NULL) card('W', width); /* * Read the files and spool them. */ if (argc == 0) copy(0, " "); else while (argc--) { if (argv[0][0] == '-' && argv[0][1] == '\0') { /* use stdin */ copy(0, " "); argv++; continue; } if ((f = test(arg = *argv++)) < 0) continue; /* file unreasonable */ if (sflag && (cp = linked(arg)) != NULL) { (void)snprintf(buf, sizeof buf, "%llu %llu", (unsigned long long)statb.st_dev, (unsigned long long)statb.st_ino); card('S', buf); if (format == 'p') card('T', title ? title : arg); for (i = 0; i < ncopies; i++) card(format, &dfname[inchar-2]); card('U', &dfname[inchar-2]); if (f) card('U', cp); card('N', arg); dfname[inchar]++; nact++; continue; } if (sflag) warnx("%s: not linked, copying instead", arg); seteuid(uid); if ((i = open(arg, O_RDONLY)) < 0) { oerrno = errno; seteuid(uid); errno = oerrno; warn("cannot open %s", arg); continue; } else { copy(i, arg); (void)close(i); if (f && unlink(arg) < 0) warn("%s: not removed", arg); } seteuid(uid); } if (nact) { (void)close(tfd); tfname[inchar]--; /* * Touch the control file to fix position in the queue. */ seteuid(euid); if ((tfd = open(tfname, O_RDWR)) >= 0) { char ch; if (read(tfd, &ch, 1) == 1 && lseek(tfd, (off_t)0, 0) == 0 && write(tfd, &ch, 1) != 1) { warn("cannot touch %s", tfname); tfname[inchar]++; cleanup(0); } (void)close(tfd); } if (link(tfname, cfname) < 0) { warn("cannot rename %s", cfname); tfname[inchar]++; cleanup(0); } unlink(tfname); seteuid(uid); if (Rflag) printf("request id is %d\n", reqid); if (qflag) /* just queue things up */ exit(0); if (!startdaemon(printer)) printf("jobs queued, but cannot start daemon.\n"); exit(0); } cleanup(0); #ifdef __GNUC__ return (0); #endif /* NOTREACHED */ }
void GLProgram::create(const GLShader& _vsh, const GLShader& _fsh) { m_id = glCreateProgram(); GLint linked(0); if (_vsh.m_id != 0) { GL_CHECK(glAttachShader(m_id, _vsh.m_id)); if (_fsh.m_id != 0) { GL_CHECK(glAttachShader(m_id, _fsh.m_id)); } GL_CHECK(glLinkProgram(m_id)); GL_CHECK(glGetProgramiv(m_id, GL_LINK_STATUS, &linked)); if (!linked) { char log[1024]; GL_CHECK(glGetProgramInfoLog(m_id, sizeof(log), NULL, log)); MOTI_TRACE("%d: %s", linked, log); } } if (!linked) { GL_CHECK(glDeleteProgram(m_id)); m_id = 0; MOTI_TRACE("Invalid shaders: vsh %d, fsh %d", _vsh.m_id, _fsh.m_id); return; } GLint numActiveAttribs{ 0 }; GLint numActiveUniforms{ 0 }; GL_CHECK(glGetProgramInterfaceiv(m_id, GL_PROGRAM_INPUT, GL_ACTIVE_RESOURCES, &numActiveAttribs)); GL_CHECK(glGetProgramInterfaceiv(m_id, GL_UNIFORM, GL_ACTIVE_RESOURCES, &numActiveUniforms)); glGetProgramiv(m_id, GL_ACTIVE_UNIFORMS, &numActiveUniforms); GLint max0, max1; GL_CHECK(glGetProgramiv(m_id, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &max0)); GL_CHECK(glGetProgramiv(m_id, GL_ACTIVE_UNIFORM_MAX_LENGTH, &max1)); uint32_t nameMaxLength = std::max(max0, max1); char* name = static_cast<char*>(alloca(nameMaxLength + 1)); MOTI_TRACE("Program %d", m_id); MOTI_TRACE("Attribute count %d", numActiveAttribs); for (int32_t i = 0; i < numActiveAttribs; ++i) { GLint size; GLenum type; glGetActiveAttrib(m_id, i, nameMaxLength + 1, nullptr, &size, &type, name); MOTI_TRACE("%s is at location %d", name, glGetAttribLocation(m_id, name)); } MOTI_TRACE("Uniform count %d", numActiveUniforms); for (int32_t i = 0; i < numActiveUniforms; ++i) { struct Info { GLenum type; GLint loc; GLint count; }; Info info; GLenum props[] = { GL_TYPE, GL_LOCATION, GL_ARRAY_SIZE }; GL_CHECK(glGetProgramResourceiv( m_id, GL_UNIFORM, i, MOTI_COUNTOF(props), props, MOTI_COUNTOF(props), NULL, (GLint*)&info)); GL_CHECK(glGetProgramResourceName( m_id, GL_UNIFORM, i, nameMaxLength + 1, NULL, name)); uint16_t count = std::max(info.count, 1); PredefinedUniform::Enum predef = nameToPredefinedUniform(name); if (predef != PredefinedUniform::Count) { m_predefinedUniforms[m_uniformCount].m_type = uint8_t(predef); m_predefinedUniforms[m_uniformCount].m_loc = info.loc; m_predefinedUniforms[m_uniformCount].m_count = count; m_uniformCount++; } else { // its user defined uniform const UniformInfo* uniformInfo = s_ctx->m_uniformReg.find(name); if (uniformInfo == nullptr) { MOTI_TRACE("User defined uniform %s is not found", name); } else { UniformType::Enum type = glTypeToUniformType(info.type); UniformDecl decl; decl.m_handle = uniformInfo->m_handle; decl.m_loc = info.loc; decl.m_count = count; decl.m_type = type; m_uniforms.push_back(decl); } } MOTI_TRACE("uniform %s is at location %d, count %d", name, info.loc, count); } memset(m_attributes, 0xff, sizeof(m_attributes)); uint32_t used(0); for (uint8_t i = 0; i < Attribute::Count; ++i) { GLint loc = glGetAttribLocation(m_id, s_attribNames[i]); if (loc != -1) { MOTI_TRACE("attribute %s: %d", s_attribNames[i], loc); m_attributes[i] = loc; m_used[used++] = i; } } MOTI_ASSERT(used < MOTI_COUNTOF(m_used), "Out of bounds %d > array size %d", used, MOTI_COUNTOF(m_used)); m_used[used] = Attribute::Count; }
void ParameterSetCanvas::menu(const QPoint &) { QPopupMenu m(0); QPopupMenu toolm(0); int index; m.insertItem(new MenuTitle(browser_node->get_data()->definition(FALSE, TRUE), m.font()), -1); m.insertSeparator(); m.insertItem(TR("Upper"), 0); m.insertItem(TR("Lower"), 1); m.insertItem(TR("Go up"), 13); m.insertItem(TR("Go down"), 14); m.insertSeparator(); m.insertItem(TR("Edit drawing settings"), 2); m.insertSeparator(); m.insertItem(TR("Edit parameter set"), 3); m.insertSeparator(); m.insertItem(TR("Select in browser"), 4); if (linked()) m.insertItem(TR("Select linked items"), 5); m.insertSeparator(); if (browser_node->is_writable()) { m.insertItem(TR("Delete from model"), 8); m.insertSeparator(); } if (Tool::menu_insert(&toolm, UmlParameterSet, 20)) m.insertItem(TR("Tool"), &toolm); switch (index = m.exec(QCursor::pos())) { case 0: act->upper(); modified(); // call package_modified() return; case 1: act->lower(); modified(); // call package_modified() return; case 13: act->z_up(); modified(); // call package_modified() return; case 14: act->z_down(); modified(); // call package_modified() return; case 2: edit_drawing_settings(); return; case 3: browser_node->open(TRUE); return; case 4: browser_node->select_in_browser(); return; case 5: the_canvas()->unselect_all(); select_associated(); return; case 8: //delete from model browser_node->delete_it(); // will delete the canvas break; default: if (index >= 20) ToolCom::run(Tool::command(index - 20), browser_node); return; } package_modified(); }
void UcUseCaseCanvas::menu(const QPoint&) { Q3PopupMenu m(0); Q3PopupMenu toolm(0); MenuFactory::createTitle(m, browser_node->get_data()->definition(FALSE, TRUE)); m.insertSeparator(); m.insertItem("Upper", 0); m.insertItem("Lower", 1); m.insertItem("Go up", 13); m.insertItem("Go down", 14); m.insertSeparator(); m.insertItem("Add related elements", 10); m.insertSeparator(); m.insertItem("Edit", 2); m.insertSeparator(); m.insertItem("Edit drawing settings", 3); m.insertSeparator(); m.insertItem("Select in browser",4); if (linked()) m.insertItem("Select linked items", 5); m.insertSeparator(); if (browser_node->is_writable()) { if (browser_node->get_associated() != (BrowserNode *) the_canvas()->browser_diagram()) m.insertItem("Set associated diagram",6); if (browser_node->get_associated()) m.insertItem("Remove diagram association",9); } m.insertSeparator(); m.insertItem("Remove from diagram",7); if (browser_node->is_writable()) m.insertItem("Delete from model", 8); m.insertSeparator(); if (Tool::menu_insert(&toolm, UmlUseCase, 20)) m.insertItem("Tool", &toolm); int rank = m.exec(QCursor::pos()); switch (rank) { case 0: upper(); modified(); return; case 1: lower(); modified(); return; case 13: z_up(); modified(); return; case 14: z_down(); modified(); return; case 2: browser_node->open(TRUE); break; case 3: edit_drawing_settings(); return; case 4: browser_node->select_in_browser(); return; case 5: the_canvas()->unselect_all(); select_associated(); return; case 6: ((BrowserUseCase *) browser_node)->set_associated_diagram((BrowserUseCaseDiagram *) the_canvas()->browser_diagram()); break; case 12: ((BrowserUseCase *) browser_node) ->set_associated_diagram(0); return; case 7: // remove from diagram delete_it(); break; case 8: // delete from model browser_node->delete_it(); // will remove canvas break; case 10: ((UmlCanvas *) canvas())->get_view() ->add_related_elements(this, TR("use case"), TRUE, FALSE); return; default: if (rank >= 20) ToolCom::run(Tool::command(rank - 20), browser_node); return; } package_modified(); }
void CodClassInstCanvas::menu(const QPoint&) { QPopupMenu m(0); bool modelized = (browser_node->get_type() == UmlClassInstance); m.insertItem(new MenuTitle(full_name(), m.font()), -1); m.insertSeparator(); m.insertItem(TR("Upper"), 0); m.insertItem(TR("Lower"), 1); m.insertItem(TR("Go up"), 13); m.insertItem(TR("Go down"), 14); m.insertSeparator(); m.insertItem(TR("Edit drawing settings"), 2); m.insertSeparator(); m.insertItem(TR("Edit"), 3); m.insertSeparator(); if (modelized) m.insertItem(TR("Select in browser"), 4); m.insertItem(TR("Select class in browser"), 5); if (linked()) m.insertItem(TR("Select linked items"), 6); m.insertSeparator(); if (modelized) m.insertItem(TR("Exit from model"), 9); else { if (container(UmlClass)->is_writable()) m.insertItem(TR("Insert in model"), 10); m.insertItem(TR("Replace it"), 11); } m.insertSeparator(); m.insertItem(TR("Remove from diagram"), 7); if (modelized && browser_node->is_writable()) m.insertItem(TR("Delete from model"), 8); switch (m.exec(QCursor::pos())) { case 0: upper(); modified(); // call package_modified return; case 1: lower(); modified(); // call package_modified return; case 13: z_up(); modified(); // call package_modified() return; case 14: z_down(); modified(); // call package_modified() return; case 2: edit_drawing_settings(); return; case 3: open(); // call package_modified return; case 4: browser_node->select_in_browser(); return; case 5: get_type()->select_in_browser(); return; case 6: the_canvas()->unselect_all(); select_associated(); return; case 7: delete_it(); break; case 8: //delete from model browser_node->delete_it(); // will delete the canvas break; case 9: { BasicData * d = browser_node->get_data(); disconnect(d, SIGNAL(changed()), this, SLOT(modified())); disconnect(d, SIGNAL(deleted()), this, SLOT(deleted())); iname = browser_node->get_name(); browser_node = ((ClassInstanceData *) d)->get_class(); d = browser_node->get_data(); connect(d, SIGNAL(changed()), this, SLOT(modified())); connect(d, SIGNAL(deleted()), this, SLOT(deleted())); } break; case 10: { BasicData * d = browser_node->get_data(); disconnect(d, SIGNAL(changed()), this, SLOT(modified())); disconnect(d, SIGNAL(deleted()), this, SLOT(deleted())); browser_node = new BrowserClassInstance(iname, (BrowserClass *) browser_node, container(UmlClass)); d = browser_node->get_data(); connect(d, SIGNAL(changed()), this, SLOT(modified())); connect(d, SIGNAL(deleted()), this, SLOT(deleted())); } break; case 11: { BrowserNode * bn = BrowserClassInstance::get_classinstance((BrowserClass *) browser_node); if (bn == 0) return; BasicData * d = browser_node->get_data(); disconnect(d, SIGNAL(changed()), this, SLOT(modified())); disconnect(d, SIGNAL(deleted()), this, SLOT(deleted())); browser_node = bn; d = browser_node->get_data(); connect(d, SIGNAL(changed()), this, SLOT(modified())); connect(d, SIGNAL(deleted()), this, SLOT(deleted())); modified(); // call package_modified return; } break; default: return; } package_modified(); }
void InfoCanvas::menu(const QPoint&) { Q3PopupMenu m(0); Q3PopupMenu fontsubm(0); MenuFactory::createTitle(m, TR("Information")); m.insertSeparator(); m.insertItem(TR("Upper"), 0); m.insertItem(TR("Lower"), 1); m.insertItem(TR("Go up"), 5); m.insertItem(TR("Go down"), 6); m.insertSeparator(); m.insertItem(TR("Edit"), 2); m.insertSeparator(); m.insertItem(TR("Font"), &fontsubm); init_font_menu(fontsubm, the_canvas(), 10); m.insertItem(TR("Edit drawing settings"), 3); if (linked()) { m.insertSeparator(); m.insertItem(TR("Select linked items"), 4); } m.insertSeparator(); int index = m.exec(QCursor::pos()); switch (index) { case 0: upper(); modified(); // call package_modified() return; case 1: lower(); modified(); // call package_modified() return; case 5: z_up(); modified(); // call package_modified() return; case 6: z_down(); modified(); // call package_modified() return; case 2: who->open(); return; case 3: for (;;) { ColorSpecVector co(1); co[0].set(TR("note color"), &itscolor); SettingsDialog dialog(0, &co, FALSE); dialog.raise(); if (dialog.exec() == QDialog::Accepted) modified(); if (!dialog.redo()) return; } break; case 4: the_canvas()->unselect_all(); select_associated(); return; default: if (index >= 10) { itsfont = (UmlFont) (index - 10); modified(); } return; } package_modified(); }
void DeploymentNodeCanvas::menu(const QPoint&) { Q3PopupMenu m(0); Q3PopupMenu toolm(0); MenuFactory::createTitle(m, browser_node->get_data()->definition(FALSE, TRUE)); m.insertSeparator(); m.insertItem(TR("Upper"), 0); m.insertItem(TR("Lower"), 1); m.insertItem(TR("Go up"), 13); m.insertItem(TR("Go down"), 14); m.insertSeparator(); m.insertItem(TR("Add related elements"), 10); m.insertSeparator(); m.insertItem(TR("Edit"), 2); m.insertSeparator(); m.insertItem(TR("Edit drawing settings"), 3); m.insertSeparator(); m.insertItem(TR("Select node in browser"), 4); if (linked()) m.insertItem(TR("Select linked items"), 5); m.insertSeparator(); m.insertItem(TR("Set node associated diagram"), 6); m.insertSeparator(); m.insertItem(TR("Remove from diagram"), 7); m.insertSeparator(); if (Tool::menu_insert(&toolm, UmlDeploymentNode, 20)) m.insertItem(TR("Tool"), &toolm); int rank = m.exec(QCursor::pos()); switch (rank) { case 0: upper(); modified(); // call package_modified() return; case 1: lower(); modified(); // call package_modified() return; case 13: z_up(); modified(); // call package_modified() return; case 14: z_down(); modified(); // call package_modified() return; case 2: open(); return; case 3: edit_drawing_settings(); return; case 4: browser_node->select_in_browser(); return; case 5: the_canvas()->unselect_all(); select_associated(); return; case 6: ((BrowserDeploymentNode *) browser_node) ->set_associated_diagram((BrowserDeploymentDiagram *) the_canvas()->browser_diagram()); return; case 7: // remove from diagram delete_it(); break; case 10: ((UmlCanvas *) canvas())->get_view() ->add_related_elements(this, TR("node"), FALSE, FALSE); return; default: if (rank >= 20) ToolCom::run(Tool::command(rank - 20), browser_node); return; } package_modified(); }
void UcClassCanvas::menu(const QPoint&) { Q3PopupMenu m(0); Q3PopupMenu toolm(0); m.insertItem(new MenuTitle(browser_node->get_data()->definition(FALSE, TRUE), m.font()), -1); m.insertSeparator(); m.insertItem(TR("Upper"), 0); m.insertItem(TR("Lower"), 1); m.insertItem(TR("Go up"), 8); m.insertItem(TR("Go down"), 9); m.insertSeparator(); m.insertItem(TR("Add related elements"), 10); m.insertSeparator(); m.insertItem(TR("Edit drawing settings"), 4); m.insertSeparator(); if (browser_node->is_writable()) { m.insertItem(TR("Edit"), 7); m.insertSeparator(); } m.insertItem(TR("Select in browser"),2); if (linked()) m.insertItem(TR("Select linked items"), 3); m.insertSeparator(); m.insertItem(TR("Remove from diagram"),5); if (browser_node->is_writable()) m.insertItem(TR("Delete from model"), 6); m.insertSeparator(); if (Tool::menu_insert(&toolm, UmlClass, 20)) m.insertItem(TR("Tool"), &toolm); int rank = m.exec(QCursor::pos()); switch (rank) { case 0: upper(); hide(); show(); break; case 1: lower(); hide(); show(); break; case 2: browser_node->select_in_browser(); return; case 3: the_canvas()->unselect_all(); select_associated(); return; case 4: edit_drawing_settings(); return; case 5: // remove from diagram delete_it(); break; case 6: // delete from model browser_node->delete_it(); // will delete the canvas break; case 7: browser_node->open(TRUE); break; case 8: z_up(); hide(); show(); break; case 9: z_down(); hide(); show(); break; case 10: ((UmlCanvas *) canvas())->get_view() ->add_related_elements(this, TR("class/actor"), TRUE, FALSE); return; default: if (rank >= 20) ToolCom::run(Tool::command(rank - 20), browser_node); return; } package_modified(); }
void Oauth2::link() { trace() << "O2::link"; if (linked()) { trace() << " Linked already"; emit linkingSucceeded(); return; } if(grantFlow_ == GrantFlowAuthorizationCode){ // Start listening to authentication replies replyServer_->listen(QHostAddress::Any, localPort_); // Save redirect URI, as we have to reuse it when requesting the access token redirectUri_ = localhostPolicy_.arg(replyServer_->serverPort()); // Assemble intial authentication URL QList<QPair<QString, QString> > parameters; parameters.append(qMakePair(QString(O2_OAUTH2_RESPONSE_TYPE), (grantFlow_ == GrantFlowAuthorizationCode) ? QString(O2_OAUTH2_CODE) : QString(O2_OAUTH2_TOKEN))); parameters.append(qMakePair(QString(O2_OAUTH2_CLIENT_ID), clientId_)); parameters.append(qMakePair(QString(O2_OAUTH2_REDIRECT_URI), redirectUri_)); // parameters.append(qMakePair(QString(OAUTH2_REDIRECT_URI), QString(QUrl::toPercentEncoding(redirectUri_)))); parameters.append(qMakePair(QString(O2_OAUTH2_SCOPE), scope_)); parameters.append(qMakePair(QString(O2_OAUTH2_API_KEY), apiKey_)); // Show authentication URL with a web browser QUrl url(requestUrl_); #if QT_VERSION < 0x050000 url.setQueryItems(parameters); #else QUrlQuery query(url); query.setQueryItems(parameters); url.setQuery(query); #endif trace() << "Emit openBrowser" << url.toString(); emit openBrowser(url); } else if(grantFlow_ == GrantFlowResourceOwnerPasswordCredentials) { QUrl url(tokenUrl_); QUrlQuery params; params.addQueryItem(O2_OAUTH2_CLIENT_ID,clientId_); params.addQueryItem(O2_OAUTH2_CLIENT_SECRET,clientSecret_); params.addQueryItem(O2_OAUTH2_USERNAME,username_); params.addQueryItem(O2_OAUTH2_PASSWORD,password_); params.addQueryItem(O2_OAUTH2_GRANT_TYPE,"password"); params.addQueryItem("device_uid", getMacAddress()); params.addQueryItem("device_name", "PC (" + QHostInfo::localHostName() + ")"); QNetworkRequest tokenRequest(url); tokenRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); QNetworkReply *tokenReply = manager_->post(tokenRequest, params.toString(QUrl::FullyEncoded).toUtf8()); connect(tokenReply, SIGNAL(finished()), this, SLOT(onTokenReplyFinished()), Qt::QueuedConnection); connect(tokenReply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onTokenReplyError(QNetworkReply::NetworkError)), Qt::QueuedConnection); } }