Пример #1
0
void PackageCanvas::prepare_for_move(bool on_resize) {
  if (! on_resize) {
    DiagramCanvas::prepare_for_move(on_resize);
    
    Q3CanvasItemList l = collisions(TRUE);
    Q3CanvasItemList::ConstIterator it;
    Q3CanvasItemList::ConstIterator end = l.end();
    DiagramItem * di;
    BrowserNode * p = get_bn();
  
    for (it = l.begin(); it != end; ++it) {
      if ((*it)->visible() && // at least not deleted
	  !(*it)->selected() &&
	  ((di = QCanvasItemToDiagramItem(*it)) != 0) &&
	  di->move_with_its_package()) {
	BrowserNode * bn = di->get_bn();
	
	do
	  bn = (BrowserNode *) bn->parent();
	while (bn->get_type() != UmlPackage);
	
	if (bn == p) {
	  the_canvas()->select(*it);
	  di->prepare_for_move(FALSE);
	}
      }
    }
  }
}
Пример #2
0
BasicData * DiagramItem::add_relation(UmlCode t, DiagramItem * end)
{
    UmlCanvas * canvas = the_canvas();

    canvas->freeze_draw_all_relations();

    BasicData * result = get_bn()->add_relation(t, end->get_bn());

    canvas->unfreeze_draw_all_relations();

    return result;
}
// update sub nodes to be upper this, recursively
void ActivityContainerCanvas::force_sub_upper(QList<QGraphicsItem*> & all)
{
    QList<QGraphicsItem*>::Iterator cit;
    BrowserNode * browser_node = get_bn();

    for (cit = all.begin(); cit != all.end(); ++cit) {
        if ((*cit)->isVisible()) {
            DiagramItem * di = QCanvasItemToDiagramItem(*cit);

            if ((di != 0) &&
                (di->get_bn() != 0) &&
                (((BrowserNode *) di->get_bn())->parent() == browser_node)) {
                // must look at the type because some canvas items have browser_node
                // attr equals to the diagram and the parent of the diagram is the activity
                switch (di->typeUmlCode()) {
                case UmlActivityObject:
                case UmlActivityAction:
                case UmlActivityPartition:
                case UmlExpansionRegion:
                case UmlInterruptibleActivityRegion:
                case InitialAN:
                case FlowFinalAN:
                case ActivityFinalAN:
                case DecisionAN:
                case MergeAN:
                case ForkAN:
                case JoinAN:
                    if ((*cit)->zValue() <= zValue())
                        ((DiagramCanvas *) di)->upper();

                    {
                        ActivityContainerCanvas * cntr =
                            dynamic_cast<ActivityContainerCanvas *>(di);

                        if (cntr != 0)
                            cntr->force_sub_upper(all);
                    }
                    break;

                default:
                    break;
                }
            }
        }
    }
}
Пример #4
0
void DiagramItem::remove_if_already_present()
{
    const UmlCode k = type();
    const BrowserNode * bn = get_bn();
    IdIterator<DiagramItem> it(the_canvas()->get_all_items());
    DiagramItem * di;

    while ((di = it.current()) != 0) {
        if ((di->type() == k) && (di->get_bn() == bn) && (di != this)) {
            // already present
            if (Undefined.isEmpty())
                msg_warning("Douml", TR("some elements already present in the diagram are NOT paste"));

            Undefined.append(this);
            return;
        }

        ++it;
    }
}
// update sub nodes position to be inside this
void ActivityContainerCanvas::force_sub_inside(QList<QGraphicsItem*> & all,
        BooL & need_sub_upper)
{
    QList<QGraphicsItem*>::Iterator cit;
    BrowserNode * browser_node = get_bn();

    for (cit = all.begin(); cit != all.end(); ++cit) {
        if ((*cit)->isVisible()/* && !(*cit)->isSelected()*/) {
            DiagramItem * di = QCanvasItemToDiagramItem(*cit);

            if ((di != 0) &&
                (di->get_bn() != 0) &&
                (((BrowserNode *) di->get_bn())->parent() == browser_node)) {
                // must look at the type because some canvas items have browser_node
                // attr equals to the diagram and the parent of the diagram is the activity
                switch (di->typeUmlCode()) {
                case UmlActivityObject:
                case UmlActivityAction:
                case UmlActivityPartition:
                case UmlExpansionRegion:
                case UmlInterruptibleActivityRegion:
                case InitialAN:
                case FlowFinalAN:
                case ActivityFinalAN:
                case DecisionAN:
                case MergeAN:
                case ForkAN:
                case JoinAN:
                    force_inside(di, *cit, need_sub_upper);
                    break;

                default:
                    break;
                }
            }
        }
    }
}
Пример #6
0
// resize this to contain its sub elements
void ActivityContainerCanvas::resize_to_contain(Q3CanvasItemList & all,
						BooL & need_sub_upper) {
  Q3CanvasItemList::Iterator cit;
  BrowserNode * browser_node = get_bn();
  QRect r = rect();
  int resize_left = 0;
  int resize_right = 0;
  int resize_top = 0;
  int resize_bottom = 0;
  
  for (cit = all.begin(); cit != all.end(); ++cit) {
    if ((*cit)->visible() && !(*cit)->selected()) {
      DiagramItem * di = QCanvasItemToDiagramItem(*cit);
      
      if ((di != 0) &&
	  (di->get_bn() != 0) &&
	  (((BrowserNode *) di->get_bn())->parent() == browser_node)) {
	// must look at the type because some canvas items have browser_node
	// attr equals to the diagram and the parent of the diagram is the activity
	switch (di->type()) {
	case UmlActivityObject:
	case UmlActivityAction:
	case UmlActivityPartition:
	case UmlExpansionRegion:
	case UmlInterruptibleActivityRegion:
	case InitialAN:
	case FlowFinalAN:
	case ActivityFinalAN:
	case DecisionAN:
	case MergeAN:
	case ForkAN:
	case JoinAN:
	  {
	    QRect di_r = di->rect();
	    int dx = 0;
	    int dy = 0;
	    
	    if (di_r.left() < r.left()) {
	      dx = r.left() - di_r.left();
	      if (dx > resize_left)
		resize_left = dx;
	    }
	    
	    if (di_r.right() > r.right()) {
	      dx = di_r.right() - r.right();
	      if (dx > resize_right)
		resize_right = dx;
	    }
	    
	    if (di_r.top() < r.top()) {
	      dy = r.top() - di_r.top();
	      if (dy > resize_top)
		resize_top = dy;
	    }
	    
	    if (di_r.bottom() > r.bottom()) {
	      dy = di_r.bottom() - r.bottom();
	      if (dy > resize_bottom)
		resize_bottom = dy;
	    }
	  }
	      
	  need_sub_upper |= ((*cit)->z() <= z());
	  break;
	default:
	  break;
	}
      }
    }
  }
  
  int dx = 0;
  int dy = 0;
  int dw = 0;
  int dh = 0;
  
  if (resize_top != 0) {
    dy = -resize_top;
    dh = resize_top;
  }
  
  if (resize_bottom != 0)
    dh += resize_bottom;
  
  if (resize_left != 0) {
    dx = -resize_left;
    dw = resize_left;
  }
  
  if (resize_right != 0)
    dw += resize_right;
  
  if ((dx != 0) || (dy != 0)) {
    moveBy(dx, dy);
    moveSelfRelsBy(dx, dy);
  }
  
  if ((dw != 0) || (dh != 0))
    DiagramCanvas::resize(width() + dw, height() + dh);
}
Пример #7
0
bool DiagramItem::represents(BrowserNode * bn)
{
    return ((type() == bn->get_type()) && (get_bn() == bn));
}
Пример #8
0
static int
load_ssh1_private(RSA *rsa, struct iovec *iov)
{
	BN_CTX *ctx;
	BIGNUM *aux;
	MD5_CTX md;
	char pass[128], comment[BUFSIZ];
	u_char *p, cipher_type, digest[16];
	void *dstate;
	int i;

	i = strlen(SSH1_MAGIC) + 1;

	/* Make sure it begins with the id string. */
	if (iov->iov_len < i || memcmp(iov->iov_base, SSH1_MAGIC, i) != 0)
		return (-1);
	
	p = (u_char *)iov->iov_base + i;
	i = iov->iov_len - i;
	
	/* Skip cipher_type, reserved data, bits. */
	cipher_type = *p;
	p += 1 + 4 + 4;
	i -= 1 + 4 + 4;

	/* Read public key. */
	if (get_bn(rsa->n, &p, &i) < 0 || get_bn(rsa->e, &p, &i) < 0)
		return (-1);
	
	/* Read comment. */
	if (get_string(comment, sizeof(comment), &p, &i) < 0)
		return (-1);
	
	/* Decrypt private key. */
	if (cipher_type != 0) {
		sign_passwd_cb(pass, sizeof(pass), 0, NULL);

		MD5_Init(&md);
		MD5_Update(&md, (const u_char *)pass, strlen(pass));
		MD5_Final(digest, &md);
		
		memset(pass, 0, strlen(pass));
		
		if ((dstate = des3_init(digest, sizeof(digest))) == NULL)
			return (-1);
		
		des3_decrypt(p, p, i, dstate);

		if (p[0] != p[2] || p[1] != p[3]) {
			fprintf(stderr, "Bad passphrase for %s\n", comment);
			return (-1);
		}
	}
	else if (p[0] != p[2] || p[1] != p[3])
		return (-1);
	
	p += 4;
	i -= 4;
	
	/* Read the private key. */
	if (get_bn(rsa->d, &p, &i) < 0 ||
	    get_bn(rsa->iqmp, &p, &i) < 0)
		return (-1);
	
	/* In SSL and SSH v1 p and q are exchanged. */
	if (get_bn(rsa->q, &p, &i) < 0 ||
	    get_bn(rsa->p, &p, &i) < 0)
		return (-1);
	
	/* Calculate p-1 and q-1. */
	ctx = BN_CTX_new();
	aux = BN_new();

	BN_sub(aux, rsa->q, BN_value_one());
	BN_mod(rsa->dmq1, rsa->d, aux, ctx);

	BN_sub(aux, rsa->p, BN_value_one());
	BN_mod(rsa->dmp1, rsa->d, aux, ctx);

	BN_clear_free(aux);
	BN_CTX_free(ctx);
	
	return (0);
}
Пример #9
0
/*
 * prodreg_unregister
 *
 * This will unregister a component unless (a) the component has
 * dependencies, in which case the command will fail and an error
 * will be output UNLESS the 'force' option is set, (b) the
 * component criteria is ambiguous, in which case the list of
 * possible matching components is returned.
 *
 *   pcRoot    An alternate root, if non-null.
 *   criteria  The component's name, uuid, browse number, etc.
 *   force     If this is set, unregister even if the component
 *             has others which depend on it.
 *   recursive Will deregister the component and all children and
 *             nodes which depend upon it.
 *
 * Returns: Nothing.
 * Side effects: Changes the state of the registry, if the user
 *     has permission to do so.
 */
void
prodreg_unregister(const char *pcRoot, Criteria criteria, int force,
    int recursive)
{
	Wsreg_component **ppws_ambig = NULL;
	Wsreg_component **ppws_dep = NULL;
	Wsreg_component *pws = NULL;
	Wsreg_component **ppws_syspkgs = NULL;
	int i;
	int result;

	if (SPECIALROOT(criteria, ROOT_UUID, ROOT_STR) ||
	    SPECIALROOT(criteria, UNCL_UUID, UNCL_STR) ||
	    SPECIALROOT(criteria, LOCL_UUID, LOCL_STR) ||
	    SPECIALROOT(criteria, ADDL_UUID, ADDL_STR) ||
	    SPECIALROOT(criteria, SYSS_UUID, SYSS_STR) ||
	    SPECIALROOT(criteria, global_ENTR_UUID, ENTR_STR) ||
	    SPECIALROOT(criteria, SYSL_UUID, SYSL_STR)) {
		fail(PRODREG_UNREGISTER);
	}

	if (pcRoot && pcRoot[0] == '\0') pcRoot = NULL;

	if ((result = wsreg_initialize(WSREG_INIT_NORMAL, pcRoot))
	    != WSREG_SUCCESS) {
		debug(DEBUGINFO, "Could not init, reason = %d\n",
		    result);
		fail(PRODREG_CONVERT_NEEDED_ACCESS);
	}

	/*
	 * Check uid is 0, otherwise we may fail later.
	 * This is a work around for the case where sometimes
	 * wsreg_can_access_registry says YES, but the answer is NO.
	 */
	if (_private_wsreg_can_access_registry(O_RDWR) == 0) {
		fail(PRODREG_CANNOT_WRITE);
	}

	/*
	 * Handle the simple mnemonic case.
	 */
	if (criteria.mask & FIND_UNAME) {
		unreg(pws, criteria, recursive);
		return;
	}

	pws = prodreg_get_component(pcRoot, criteria, 0, &ppws_ambig,
	    &ppws_syspkgs);
	if (pws == NULL)
		fail(PRODREG_NO_SUCH_COMPONENT);

	db_open();

	if (ppws_ambig) {
		if (force == 0) {
			(void) printf(PRODREG_AMBIGUOUS_RESULTS);
			(void) printf("\n");
			browse_header();
		}

		for (i = 0; ppws_ambig[i]; i++) {
			if (force) {
				unreg(ppws_ambig[i], criteria, 0);
			} else {
				Wsreg_component **p =
				    wsreg_get_child_references(ppws_ambig[i]);
				fill_in_comps(p, ppws_syspkgs);

				show(NODE, 1, 0, get_bn(ppws_ambig[i]->id),
				    ppws_ambig[i]->id, ppws_ambig[i]->instance,
				    wsreg_get_display_name(ppws_ambig[i],
					global_lang));

				if (p) {
					wsreg_free_component_array(p);
					p = NULL;
				}
			}
		}
		if (ppws_syspkgs)
			wsreg_free_component_array(ppws_syspkgs);

		return;
	}

	/* This will exit if pws has dependents, unless forced. */
	check_dependent(recursive, force, pws, PRODREG_UNREG_WOULD_BREAK);

	unreg(pws, criteria, recursive);

	wsreg_free_component(pws);
	if (ppws_dep) wsreg_free_component_array(ppws_dep);
	if (ppws_syspkgs) wsreg_free_component_array(ppws_syspkgs);
	db_close();
}