Exemplo n.º 1
0
int
main (int argc, char **argv)
{
  GError *error = NULL;
  GOptionContext *context;
  char **l;

  context = g_option_context_new ("- Carrick/ConnMan 3G connection wizard");
  g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
  g_option_context_add_group (context, gtk_get_option_group (TRUE));
  if (!g_option_context_parse (context, &argc, &argv, &error)) {
    g_printerr ("option parsing failed: %s\n", error->message);
    exit (1);
  }

  connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
  if (connection == NULL) {
    g_printerr ("Cannot connect to DBus: %s\n", error->message);
    g_error_free (error);
    exit (1);
  }

  if (service_paths) {
    for (l = service_paths; *l; l++) {
      GggService *service;

      service = ggg_service_new (connection, *l);
      if (service)
        services = g_list_prepend (services, service);
    }
  }

  if (add_fake) {
    services = g_list_prepend (services, ggg_service_new_fake ("Fake Device 1", FALSE));
    services = g_list_prepend (services, ggg_service_new_fake ("Fake Device 2", TRUE));
  }

  /* Scan connman for services if none were found */
  if (services == NULL)
    find_services ();

  gtk_window_set_default_icon_name ("network-wireless");

  state = STATE_START;
  state_machine ();

  show_network_panel ();

  return 0;
}
CIMHandleIndicationResponseMessage*
IndicationHandlerService::_handleIndication(
    CIMHandleIndicationRequestMessage* request)
{
    PEG_METHOD_ENTER (TRC_IND_HANDLE,
                      "IndicationHandlerService::_handleIndication");

    CIMException cimException =
        PEGASUS_CIM_EXCEPTION(CIM_ERR_SUCCESS, String::EMPTY);

    CIMName className = request->handlerInstance.getClassName();
    CIMNamespaceName nameSpace = request->nameSpace;

    CIMInstance indication = request->indicationInstance;
    CIMInstance handler = request->handlerInstance;

    Uint32 pos = PEG_NOT_FOUND;

    if (className.equal (PEGASUS_CLASSNAME_INDHANDLER_CIMXML) ||
        className.equal (PEGASUS_CLASSNAME_LSTNRDST_CIMXML))
    {
        pos = handler.findProperty(PEGASUS_PROPERTYNAME_LSTNRDST_DESTINATION);

        if (pos == PEG_NOT_FOUND)
        {
            cimException = PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
                MessageLoaderParms("HandlerService.IndicationHandlerService."
                "CIMXML_HANDLER_WITHOUT_DESTINATION", "CIMXml Handler missing Destination property"));
        }
        else
        {
            CIMProperty prop = handler.getProperty(pos);
            String destination = prop.getValue().toString();

            if (destination.size() == 0)
            {
                cimException = PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
                    MessageLoaderParms("HandlerService.IndicationHandlerService."
                    "INVALID_DESTINATION", "invalid destination"));
            }
//compared index 10 is not :
            else if (destination.subString(0, 10) == String("localhost/"))
            {
                Array<Uint32> exportServer;

                    find_services(PEGASUS_QUEUENAME_EXPORTREQDISPATCHER, 0, 0,
                          &exportServer);

                // Listener is build with Cimom, so send message to ExportServer

               AutoPtr<CIMExportIndicationRequestMessage> exportmessage( 
		    new CIMExportIndicationRequestMessage(
                    XmlWriter::getNextMessageId(),
                    destination.subString(21), //taking localhost/CIMListener portion out from reg
                    indication,
                    QueueIdStack(exportServer[0], getQueueId()),
                    String::EMPTY,
                    String::EMPTY));

                exportmessage->operationContext.set(
		    request->operationContext.get(
		    ContentLanguageListContainer::NAME)); 
                AutoPtr<AsyncOpNode> op( this->get_op());

                AutoPtr<AsyncLegacyOperationStart> asyncRequest(
		    new AsyncLegacyOperationStart(
                    get_next_xid(),
                    op.get(),
                    exportServer[0],
                    exportmessage.get(),
                    _queueId));
                exportmessage.release();

                PEG_TRACE_STRING(TRC_IND_HANDLE, Tracer::LEVEL4,
                   "Indication handler forwarding message to " +
                   ((MessageQueue::lookup(exportServer[0])) ?
                   String( ((MessageQueue::lookup(exportServer[0]))->
                       getQueueName()) ) :
                   String("BAD queue name")));

                //SendAsync(op,
                //      exportServer[0],
                //      IndicationHandlerService::_handleIndicationCallBack,
                //      this,
                //      (void *)request->queueIds.top());
                AutoPtr<AsyncReply> asyncReply(SendWait(asyncRequest.get()));
	        asyncRequest.release();

                // Return the ExportIndication results in HandleIndication 
		//response
                AutoPtr<CIMExportIndicationResponseMessage> exportResponse(
		    reinterpret_cast<CIMExportIndicationResponseMessage *>(
                    (static_cast<AsyncLegacyOperationResult *>(
			asyncReply.get()))->get_result()));
                cimException = exportResponse->cimException;

                op->release();
                this->return_op(op.release());
            }
	    else
	    {
                _loadHandler(request, cimException);
	    }
        }
    }
    else if (className.equal (PEGASUS_CLASSNAME_INDHANDLER_SNMP))
    {
        pos = handler.findProperty(PEGASUS_PROPERTYNAME_LSTNRDST_TARGETHOST);

        if (pos == PEG_NOT_FOUND)
        {
            cimException = PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
                MessageLoaderParms("HandlerService.IndicationHandlerService."
                "SNMP_HANDLER_WITHOUT_TARGETHOST", "Snmp Handler missing Targethost property"));
        }
        else
        {
            CIMProperty prop = handler.getProperty(pos);
            String destination = prop.getValue().toString();

            if (destination.size() == 0)
            {
                cimException = PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
                MessageLoaderParms("HandlerService.IndicationHandlerService."
                    "INVALID_TARGETHOST", "invalid targethost"));
            }
	    else
            {
                _loadHandler(request, cimException);
            }
        }
    }
    else if ((className.equal (PEGASUS_CLASSNAME_LSTNRDST_SYSTEM_LOG)) ||
	     (className.equal (PEGASUS_CLASSNAME_LSTNRDST_EMAIL)))
    {
        _loadHandler(request, cimException);
    }

    CIMHandleIndicationResponseMessage* response =
        new CIMHandleIndicationResponseMessage(
            request->messageId,
            cimException,
            request->queueIds.copyAndPop());

    delete request;
    return response;
}