//============================================================================ int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { int err = 0; try { // Contact the orb orb = CORBA::ORB_init (argc, argv); // Scan through the command line options bool failed = false, showNSonly = false; ACE_TCHAR kindsep = ACE_TEXT('.'); ACE_TCHAR ctxsep[] = ACE_TEXT("/"); ACE_TCHAR *name = 0; const ACE_TCHAR *const pname = argv[0]; const ACE_TCHAR *nameService = 0; if (0 < argc) { while (0 < --argc) { ++argv; if (0 == ACE_OS::strcmp (*argv, ACE_TEXT ("--ns"))) { if (!--argc) { ACE_DEBUG ((LM_DEBUG, "Error: --ns requires an argument\n")); failed = true; } else { ++argv; if (nameService) { ACE_DEBUG ((LM_DEBUG, "Error: more than one --ns.\n")); failed = true; } else if (showNSonly) { ACE_DEBUG ((LM_DEBUG, "Error: --nsior and --ns " "are both specified\n")); failed = true; } else nameService = *argv; } } else if (0 == ACE_OS::strcmp (*argv, ACE_TEXT ("--nsior"))) { if (showIOR || showCtxIOR || noLoops || nameService || name || maxDepth) { ACE_DEBUG ((LM_DEBUG, "Error: --nsior given " "with other options\n")); failed = true; } else showNSonly = true; } else if (0 == ACE_OS::strcmp(*argv, ACE_TEXT ("--ior"))) { if (showNSonly) { ACE_DEBUG ((LM_DEBUG, "Error: --nsior and --ior are " "both specified\n")); failed = true; } else showIOR = true; } else if (0 == ACE_OS::strcmp (*argv, ACE_TEXT ("--ctxior"))) { if (showNSonly) { ACE_DEBUG ((LM_DEBUG, "Error: --nsior and --ctxior are " "both specified\n")); failed = true; } else showCtxIOR = true; } else if (0 == ACE_OS::strcmp (*argv, ACE_TEXT ("--tree"))) { if (!--argc) { ACE_DEBUG ((LM_DEBUG, "Error: --tree requires an argument\n")); failed = true; } else { ++argv; if (showNSonly) { ACE_DEBUG ((LM_DEBUG, "Error: --nsior and --tree are " "both specified\n")); failed = true; } else myTree = ACE_TEXT_ALWAYS_CHAR (*argv); } } else if (0 == ACE_OS::strcmp (*argv, ACE_TEXT ("--node"))) { if (!--argc) { ACE_DEBUG ((LM_DEBUG, "Error: --node requires an argument\n")); failed = true; } else { ++argv; if (showNSonly) { ACE_DEBUG ((LM_DEBUG, "Error: --nsior and --node are " "both specified\n")); failed = true; } else myNode = ACE_TEXT_ALWAYS_CHAR (*argv); } } else if (0 == ACE_OS::strcmp(*argv, ACE_TEXT ("--noloops"))) { if (showNSonly) { ACE_DEBUG ((LM_DEBUG, "Error: --nsior and --noloops are " "both specified\n")); failed = true; } else noLoops = true; } else if (0 == ACE_OS::strcmp (*argv, ACE_TEXT ("--name"))) { if (name) { ACE_DEBUG ((LM_DEBUG, "Error: more than one --name\n")); failed = true; } else if (!--argc) { ACE_DEBUG ((LM_DEBUG, "Error: --name requires an argument\n")); failed = true; } else { ++argv; if (showNSonly) { ACE_DEBUG ((LM_DEBUG, "Error: --nsior and --name are " "both specified\n")); failed = true; } else name = *argv; } } else if (0 == ACE_OS::strcmp (*argv, ACE_TEXT ("--ctxsep"))) { if (!--argc) { ACE_DEBUG ((LM_DEBUG, "Error: --ctxsep requires a character\n")); failed = true; } else if (1 != ACE_OS::strlen(*(++argv))) { ACE_DEBUG ((LM_DEBUG, "Error: --ctxsep takes a single character (not %s)\n", *argv)); failed = true; } else if (showNSonly) { ACE_DEBUG ((LM_DEBUG, "Error: --nsior and --ctxsep are " "both specified\n")); failed = true; } else ctxsep[0] = (*argv)[0]; } else if (0 == ACE_OS::strcmp (*argv, ACE_TEXT ("--kindsep"))) { if (!--argc) { ACE_DEBUG ((LM_DEBUG, "Error: --kindsep requires a character\n")); failed = true; } else if (1 != ACE_OS::strlen(*(++argv))) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Error: --kindsep takes a single ") ACE_TEXT ("character (not %s)\n"), *argv)); failed = true; } else if (showNSonly) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Error: --nsior and --kindsep are ") ACE_TEXT ("both specified\n"))); failed = true; } else kindsep = (*argv)[0]; } else if (0 == ACE_OS::strcmp(*argv, ACE_TEXT ("--max"))) { if (maxDepth) { ACE_DEBUG ((LM_DEBUG, "Error: --max given more than once\n")); failed = true; } else if (!--argc || !ACE_OS::ace_isdigit (ACE_TEXT_ALWAYS_CHAR (*(++argv))[0])) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Error: --max requires a number\n"))); failed = true; } else if (showNSonly) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Error: --nsior and --max are ") ACE_TEXT ("both specified\n"))); failed = true; } else maxDepth= ACE_OS::atoi (*argv); } else if (0 == ACE_OS::strcmp(*argv, ACE_TEXT ("--rtt"))) { if (rtt != ACE_Time_Value::zero) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Error: --rtt given more than once\n"))); failed = true; } else if (!--argc || !ACE_OS::ace_isdigit (ACE_TEXT_ALWAYS_CHAR (*(++argv))[0])) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Error: --rtt requires a number\n"))); failed = true; } else rtt.set (ACE_OS::atoi (*argv), 0); } else if (0 == ACE_OS::strcmp(*argv, ACE_TEXT ("--count"))) { if (max_count != MAX_COUNT_DEFAULT) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Error: --count given more than once\n"))); failed = true; } else if (!--argc || !ACE_OS::ace_isdigit (ACE_TEXT_ALWAYS_CHAR (*(++argv))[0])) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Error: --count requires a number\n"))); failed = true; } else { CORBA::ULong count = ACE_OS::strtoul (ACE_TEXT_ALWAYS_CHAR (*argv), 0, 10); if (count > 0) { max_count = count; } else { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Error: --count requires a number") ACE_TEXT (" greater than 0\n"))); failed = true; } } } else { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Unknown option %s\n"), *argv)); failed = true; } } } if (failed) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n%s options:\n") ACE_TEXT (" --nsior {Display the naming service IOR and exit}\n") ACE_TEXT ("or:\n") ACE_TEXT (" --ns <ior> {Defaults to standard NameService}\n") ACE_TEXT (" --ior {Display ior for end points}\n") ACE_TEXT (" --ctxior {Display ior for naming contexts}\n") ACE_TEXT (" --tree \"xx\" {Defaults to | for drawing tramlines}\n") ACE_TEXT (" --node \"xx\" {Defaults to + for drawing nodes}\n") ACE_TEXT (" --noloops {Inhibit drawing of naming context loops}\n") ACE_TEXT (" --name <name> {Lists sub-set, defaults to root}\n") ACE_TEXT (" --ctxsep <character> {<name> Context separation character, default /}\n") ACE_TEXT (" --kindsep <character> {<name> ID/Kind separation character, default .}\n") ACE_TEXT (" --max <number> {If given, limits displayed sub-context depth}\n") ACE_TEXT (" --rtt <seconds> {If given, sets the relative round trip timeout policy}\n") ACE_TEXT (" --count <number> {If given, sets the maximum ") ACE_TEXT ("number of entries per request from the NameService}\n"), pname)); orb->destroy (); return 1; } // Initialise the lengths of the myTree and myNode draw strings. sizeMyTree= ACE_OS::strlen (myTree); sizeMyNode= ACE_OS::strlen (myNode); // Contact the name service CORBA::Object_var obj; if (nameService) obj = orb->string_to_object (nameService); else obj = orb->resolve_initial_references ("NameService"); obj = set_rtt(obj.in ()); CosNaming::NamingContext_var root_nc = CosNaming::NamingContext::_narrow (obj.in ()); if (CORBA::is_nil (root_nc.in ())) { ACE_DEBUG ((LM_DEBUG, "Error: nil root naming context\n")); orb->destroy (); return 1; } if (name) { // Assemble the name from the user string given CosNaming::Name the_name (0); ACE_TCHAR *cp; while (0 != (cp = ACE_OS::strtok (name, ctxsep))) { const int index= the_name.length(); the_name.length (index+1); ACE_TCHAR *kind = const_cast<ACE_TCHAR*> (ACE_OS::strchr (cp, kindsep)); if (kind) { *kind = '\0'; the_name[index].kind= CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR(++kind)); } the_name[index].id = CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR(cp)); name = 0; // way strtok works } // Now find this sub-context and replace the root with it. obj = root_nc->resolve( the_name ); root_nc = CosNaming::NamingContext::_narrow (obj.in ()); if (CORBA::is_nil (root_nc.in ())) { ACE_DEBUG ((LM_DEBUG, "Error: Can't find naming context\n %s\n", name)); orb->destroy (); return 1; } } CORBA::String_var str = orb->object_to_string (root_nc.in ()); if (showNSonly) { ACE_DEBUG ((LM_DEBUG, "The NameService is located via:\n%C\n", str.in ())); } else { ACE_DEBUG ((LM_DEBUG, "Naming Service: %C\n---------------\n", ((showCtxIOR)? str.in () : ""))); list_context (root_nc.in (), 1, max_count); } } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Exception in nslist"); ++err; } try { orb->destroy (); } catch (const CORBA::Exception& ex) { ACE_DEBUG ((LM_DEBUG, "\nError:\n")); ex._tao_print_exception ("Exception in while shutting down"); ++err; } return err; }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); dirModel = new QFileSystemModel(this); ui->listView->setModel(dirModel); ruleModel = new QStandardItemModel(0, 3, this); QStringList headers; headers << "Contains" << "Extension" << "Destination"; ruleModel->setHorizontalHeaderLabels(headers); ruleModel->appendRow(NULL); ui->tableView->setModel(ruleModel); ui->tableView->setColumnWidth(1,70); ui->tableView->horizontalHeader()->setStretchLastSection(true); ui->listView->setSelectionMode(QAbstractItemView::ExtendedSelection); ui->listView->setContextMenuPolicy(Qt::CustomContextMenu); ui->listView->connect(ui->listView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(list_context(QPoint))); }