Ejemplo n.º 1
0
void CDragBar::OnLeftDown(wxMouseEvent& evt)
{
  const int idx = FindToolFromCoords(evt.GetPosition());
  if (idx == -1)
    return;

  wxASSERT(idx >= 0 && size_t(idx) < m_items.size());

  wxString text = m_provider->GetText(m_items[idx].id);
  if (!text.IsEmpty()) {
    wxTextDataObjectEx dataObj(text);
    wxDropSource source(dataObj, this);//, wxDROP_ICON(DragbarElements[idx].name));
    switch (source.DoDragDrop()) {
      case wxDragError:
        wxLogDebug(_("Error dragging"));
        break;
      case wxDragNone:
        wxLogDebug(_("Nothing happened dragging"));
        break;
      case wxDragCopy:
        wxLogDebug(_("Copied successfully"));
        break;
      case wxDragMove:
        wxLogDebug(_("Moved successfully"));
        break;
      case wxDragCancel:
        wxLogDebug(_("Dragging cancelled"));
        break;
      default:
        wxLogDebug(_("Unexpected result dragging"));
        break;
    }
  }
}
Ejemplo n.º 2
0
void VCardXXPort::addKey( KABC::Addressee &addr, KABC::Key::Types type )
{
  QString fingerprint = addr.custom( "KADDRESSBOOK",
                                     (type == KABC::Key::PGP ? "OPENPGPFP" : "SMIMEFP") );
  if ( fingerprint.isEmpty() )
    return;

  GpgME::Context * context = GpgME::Context::createForProtocol( GpgME::Context::OpenPGP );
  if ( !context ) {
    kdError() << "No context available" << endl;
    return;
  }

  context->setArmor( false );
  context->setTextMode( false );

  QGpgME::QByteArrayDataProvider dataProvider;
  GpgME::Data dataObj( &dataProvider );
  GpgME::Error error = context->exportPublicKeys( fingerprint.latin1(), dataObj );
  delete context;

  if ( error ) {
    kdError() << error.asString() << endl;
    return;
  }

  KABC::Key key;
  key.setType( type );
  key.setBinaryData( dataProvider.data() );

  addr.insertKey( key );
}
/*
 * This function works pretty much like routTcpMessage only that this one interpretes message from RFIDMonitor and don't verify packages size.
 * it only tries to interpret data just arrived.
 */
void RFIDMonitorDaemon::routeIpcMessage()
{
    QByteArray message = ipcConnection->readAll();
    json::NodeJSMessage nodeMessage;

    nodeMessage.read(QJsonDocument::fromJson(message).object());
    QString messageType(nodeMessage.type());

    if(messageType == "SYN"){

        m_restoreTimer.stop();
        ipcSendMessage(buildMessage(QJsonObject(), "ACK-SYN").toJson());
        qApp->processEvents();

        /* When the deskApp change some configuration the RFIDMonitor is restarted.
         * But, the RFIDMonitor starts with flag connection=false. And if the server is connected the RFIDMonitor don't know that yet.
         * To solve this, after 1 seconds a SYNC message is sent to RFIDMonitor to set true to connection flag.
         */
        if(isConnected)
        {
            QTimer *timer = new QTimer();
            timer->setSingleShot(true);
            timer->setInterval(1000);
            connect(timer, &QTimer::timeout, [=](){
                ipcSendMessage(buildMessage(QJsonObject(), "SYNC").toJson());
                timer->deleteLater();
            });
            timer->start();
        }

        m_configManager->restartNetwork();

    }else if (messageType == "READER-RESPONSE") {
        QJsonObject command(nodeMessage.jsonData());
        /*
         * When a 'reader response' message is received is because someone sent a 'reader command' message. So it needs to know who did it.
         * To perform this it uses a field called 'sender' that carry the name of who sent the 'command message'.
         * And based on that, it will respond to the server connection or to the deskApp connection.
         *
         * see reoutTcpMessage (messageType == "READER-COMMAND")
         */
        if(command.value("sender").toString() == "server")
            tcpSendMessage(m_tcpSocket, message);
        else
            tcpSendMessage(m_tcpAppSocket, message);

    }else if (messageType == "DATA"){
        /*
         * A Data message means that the RFIDMonitor is trying to sync some data into the server. So, it just send this message to the server.
         */
//        qDebug() <<  "DATA Message Received from Monitor\n";
//        qDebug() <<  QString(QJsonDocument(nodeMessage.jsonData()).toJson());
        // Only a node.js server receives DATA messages.
        tcpSendMessage(m_tcpSocket, message);

    }else if (messageType == "STOPPED"){
        qDebug() << "STOPPED";
        m_process.kill();
//        qDebug() << "Process Killed, PID: " << m_process.pid();
    }
    else if (messageType == "ACK-UNKNOWN") {
        QJsonDocument unknown(nodeMessage.jsonData());
        QJsonObject dataObj(unknown.object().value("unknownmessage").toObject());
        qDebug() <<  "The Monitor don't understand the message type: "
                        << dataObj.value("type").toString();
    }
    else{
        /* When receives a message that can't be interpreted like any type is an unknown message.
         * In this case an ACK-UNKNOWN message is built and sent to the connection that received this message
         */
        qDebug() <<  "UNKNOWN MESSAGE";

        QJsonObject unknownObj;
        unknownObj.insert("unknownmessage", QJsonDocument::fromJson(message).object());
        unknownObj.insert("errorinfo", QString("Unknown message received"));

        ipcSendMessage(buildMessage(unknownObj, "ACK-UNKNOWN").toJson());
    }
}
Ejemplo n.º 4
0
// -----------------------------------------------------------------------
// Construct a fully qualified table name.
// -----------------------------------------------------------------------
Lng32 AddTableName( const hs_table_type type
                 , const char *table
                 , const char *schema
                 , const char *catalog
                 )
  {
    HSGlobalsClass *hs_globals = GetHSContext();
    NAString catName, schName, objName;
    NAString extName;
    NAString defaultCat, defaultSch;
    NAString userLocation;
    Lng32 retcode = 0;

    hs_globals->tableType = type;
    HSLogMan *LM = HSLogMan::Instance();
  
    // SET MPLOC is converted to CQD (setting values for default
    // attributes MP_SYSTEM, MP_VOLUME, MP_SUBVOLUME).  It does not
    // update the global MPLOC value stored in SqlParser_MPLOC.  The
    // following updates the global MPLOC value to be consistent with
    // the default attribute values set by SET MPLOC/CQD.
    ActiveSchemaDB()->getDefaults().getSqlParser_NADefaults();

    if (type == GUARDIAN_TABLE)
      {
        if (*table == '$')
          { // Qualify with system name.
            extName  = SqlParser_MPLOC.getSystemName();
            extName += ".";
            extName += table;
          }
        else
          extName = table;
        hs_globals->tableFormat = SQLMP;
      }
    else
      {
        // When CQD DEFAULT_SCHEMA_ACCESS_ONLY is on, 
        // users cannot update stats on tables not in the default/public schemas.
        if ( schema && 
             ActiveSchemaDB()->getDefaults().getToken(DEFAULT_SCHEMA_ACCESS_ONLY)==DF_ON )
        {
          SchemaName objSchName;
          NAString curSchName(schema);
          NAString curCatName;
          objSchName.setSchemaName(curSchName);
          if (catalog)
          {
            curCatName = catalog;
            objSchName.setCatalogName(curCatName);
          }
          else
            curCatName = ActiveSchemaDB()->getDefaultSchema().getCatalogName();

          // If the schema is neither default nor public,
          // issue inaccessible error.
          if (!objSchName.matchDefaultPublicSchema())
          {
            NAString dataObj(curCatName);
            if (!dataObj.isNull()) dataObj += ".";
            dataObj += curSchName + ".";
            dataObj += table;
            HSFuncMergeDiags(-UERR_OBJECT_INACCESSIBLE, dataObj.data());
            retcode = -1;
            HSHandleError(retcode);
          }
        }

        if (catalog)
          catName = catalog;
        else
          {
            // LCOV_EXCL_START :nsk
            if (SqlParser_NAMETYPE == DF_NSK)
              {
                catName = SqlParser_MPLOC.getSysDotVol();
                hs_globals->tableType = GUARDIAN_TABLE;
                hs_globals->tableFormat = SQLMP;
              }
            else
            // LCOV_EXCL_STOP
              catName = ActiveSchemaDB()->getDefaultSchema().getCatalogName();
          }
  
        if (schema)
          schName = schema;
        else
          {
            // LCOV_EXCL_START :nsk
            if (SqlParser_NAMETYPE == DF_NSK)
              {
                schName = SqlParser_MPLOC.getSubvolName();
                hs_globals->tableFormat = SQLMP;
              }
            else
            // LCOV_EXCL_STOP
              schName = ActiveSchemaDB()->getDefaultSchema().getSchemaName();
          }
  
        objName = table;
        extName = catName + "." + schName + "." + objName;
      }
  
    // LCOV_EXCL_START :nsk
    if (hs_globals->tableFormat == SQLMP)
      {
        ComMPLoc loc(extName, ComMPLoc::FILE);
        if (loc.getFormat() == ComMPLoc::INVALID)
          {
            HSFuncMergeDiags(-UERR_OBJECT_INACCESSIBLE, extName);
            retcode = -1;
            HSHandleError(retcode);
          }
  
        catName = loc.getSysDotVol();
        schName = loc.getSubvolName();
        objName = loc.getFileName();
      }
    // LCOV_EXCL_STOP

    hs_globals->objDef = NULL;
    
    // Search in volatile schema first. If not found, search in regular cat/sch.
    if ((CmpCommon::context()->sqlSession()->volatileSchemaInUse()) &&
        (type != GUARDIAN_TABLE) &&
        (! catalog))
      {
        // search using the volatile schema name.
        NAString &volCatName = CmpCommon::context()->sqlSession()->volatileCatalogName();
        NAString &volSchName = CmpCommon::context()->sqlSession()->volatileSchemaName();
        NAString volObjName = table;
	
        
        ComObjectName volIntName(volCatName, volSchName, volObjName,
                                 COM_UNKNOWN_NAME, 
                                 ComAnsiNamePart::INTERNAL_FORMAT);
        if (NOT volIntName.isValid())
          {
            LM->Log("***[ERROR] Unable to create an ObjectClass");
            HSFuncMergeDiags(-UERR_OBJECT_INACCESSIBLE, extName);
            retcode = -1;
            HSHandleError(retcode);
          }
	
        if (LM->LogNeeded())
          {
            LM->Log("Searching in volatile schema, since catalog not specified.\n");
            sprintf(LM->msg, "Checking volatile name (volIntName) %s.%s.%s\n",
                    volIntName.getCatalogNamePart().getInternalName().data(),
                    volIntName.getSchemaNamePart().getInternalName().data(),
                    volIntName.getObjectNamePart().getInternalName().data());
            LM->Log(LM->msg);
          }

        hs_globals->objDef = HSTableDef::create(STMTHEAP,
                                                volIntName,
                                                hs_globals->tableType,
                                                hs_globals->nameSpace);
      	if (NOT hs_globals->objDef->objExists(HSTableDef::MAX_INFO))
          {
            // now look into the regular schema
            delete hs_globals->objDef;
            hs_globals->objDef = NULL;
          }
        else 
          {
            // if schema name was specified, validate that it is the
            // current username.
            if (schema)
              {
                QualifiedName qn(volObjName, schName);
                if (NOT CmpCommon::context()->sqlSession()->validateVolatileQualifiedName(qn))
                  {
                    // table was found in the volatile schema but it is
                    // not a valid volatile name.
                    // Look for it in regular schema.
                    // error info was moved to CmpCommon::diags. Clear it.
                    CmpCommon::diags()->clear();
                    delete hs_globals->objDef;
                    hs_globals->objDef = NULL;
                  }
              }
          }
      }      
    
    if (hs_globals->objDef == NULL)
      {
	ComObjectName intName(catName, schName, objName,
			      COM_UNKNOWN_NAME, 
			      ComAnsiNamePart::INTERNAL_FORMAT);
	if (NOT intName.isValid())
	  {
	    LM->Log("***[ERROR] Unable to create an ObjectClass");
	    HSFuncMergeDiags(-UERR_OBJECT_INACCESSIBLE, extName);
	    retcode = -1;
	    HSHandleError(retcode);
	  }
	

  hs_globals->objDef = HSTableDef::create(STMTHEAP,
                                          intName,
                                          hs_globals->tableType,
                                          hs_globals->nameSpace);

  // try public schema if an object is not qualified and not found
  if ((NOT schema) && 
      (NOT hs_globals->objDef->objExists(HSTableDef::MAX_INFO)))
	  {
      NAString pubSch = ActiveSchemaDB()->getDefaults().getValue(PUBLIC_SCHEMA_NAME);
      ComSchemaName pubSchema(pubSch);
      if (NOT pubSchema.getSchemaNamePart().isEmpty())
      {
        NAString pubSchName = pubSchema.getSchemaNamePart().getInternalName();
        NAString pubCatName = (pubSchema.getCatalogNamePart().isEmpty() ? 
          catName:pubSchema.getCatalogNamePart().getInternalName());
      	ComObjectName pubIntName(pubCatName, pubSchName, objName,
			                           COM_UNKNOWN_NAME, ComAnsiNamePart::INTERNAL_FORMAT);
	      if (pubIntName.isValid())
	      {
          HSTableDef *pubObjDef = HSTableDef::create(STMTHEAP,
                                                     pubIntName, 
                                                     hs_globals->tableType,
                                                     hs_globals->nameSpace);
          if (pubObjDef->objExists(HSTableDef::MAX_INFO))
          {
            hs_globals->objDef = pubObjDef;
          }
	      }
      }
	  }

	if (NOT hs_globals->objDef->objExists(HSTableDef::MAX_INFO))
	  {
	    HSFuncMergeDiags(-UERR_OBJECT_INACCESSIBLE, extName);
	    retcode = -1;
	    HSHandleError(retcode);
	  }
      }

    //10-040123-2660 We only support tables. We do not allow views.
    // Tables can be metadata tables.
    if ((hs_globals->objDef->getObjectType() != COM_BASE_TABLE_OBJECT) &&
        (hs_globals->objDef->getObjectType() != COM_MV_OBJECT)) 
      {
        HSFuncMergeDiags(-UERR_INVALID_OBJECT, extName);
        retcode = -1;
        HSHandleError(retcode);
      }
    retcode = hs_globals->objDef->getColumnNames();
    HSFuncExecQuery("CONTROL QUERY DEFAULT DISPLAY_DIVISION_BY_COLUMNS RESET");
    HSHandleError(retcode);

    hs_globals->tableFormat = hs_globals->objDef->getObjectFormat();
    *hs_globals->catSch     = hs_globals->objDef->getPrimaryLoc(HSTableDef::EXTERNAL_FORMAT);
    *hs_globals->user_table = hs_globals->objDef->getObjectFullName();
    hs_globals->tableFormat = hs_globals->objDef->getObjectFormat();
    hs_globals->isHbaseTable = HSGlobalsClass::isHbaseCat(catName);

    if (hs_globals->tableFormat == SQLMX)
      {
        // Determine the schema version for this MX table.
        if (LM->LogNeeded())
         {
            sprintf(LM->msg, "\nCHECK SCHEMA VERSION FOR TABLE: %s\n", 
              hs_globals->user_table->data());
            LM->Log(LM->msg);
         }
        HSGlobalsClass::schemaVersion = getTableSchemaVersion(hs_globals->user_table->data());
        // LCOV_EXCL_START :rfi
        if (HSGlobalsClass::schemaVersion == COM_VERS_UNKNOWN)
        {
           HSFuncMergeDiags(-UERR_INTERNAL_ERROR, "GET_SCHEMA_VERSION");
           return -1;
        }
        // LCOV_EXCL_STOP


        if (HSGlobalsClass::schemaVersion >= COM_VERS_2300) 
          HSGlobalsClass::autoInterval = CmpCommon::getDefaultLong(USTAT_AUTOMATION_INTERVAL);
        if (LM->LogNeeded())
         {
            sprintf(LM->msg, "\nUpdateStats: TABLE: %s; SCHEMA VERSION: %d; AUTOMATION INTERVAL: %d\n", 
                  hs_globals->user_table->data(), 
                  HSGlobalsClass::schemaVersion, HSGlobalsClass::autoInterval);
            LM->Log(LM->msg);
         }

        const char* period = strchr(hs_globals->catSch->data(), '.');
        NAString catName(hs_globals->catSch->data(),
                         period - hs_globals->catSch->data());
        NABoolean isHbaseOrHive = HSGlobalsClass::isHbaseCat(catName) ||
                                  HSGlobalsClass::isHiveCat(catName);

        *hs_globals->hstogram_table = 
            getHistogramsTableLocation(hs_globals->catSch->data(), FALSE);
        if (isHbaseOrHive)
          hs_globals->hstogram_table->append(".").append(HBASE_HIST_NAME);
        else
          hs_globals->hstogram_table->append(".HISTOGRAMS");

        *hs_globals->hsintval_table = 
            getHistogramsTableLocation(hs_globals->catSch->data(), FALSE);
        if (isHbaseOrHive)
          hs_globals->hsintval_table->append(".").append(HBASE_HISTINT_NAME);
        else
          hs_globals->hsintval_table->append(".HISTOGRAM_INTERVALS");
      }
    else
      {
        // LCOV_EXCL_START :nsk
        *hs_globals->hstogram_table = hs_globals->objDef->getCatalogLoc(HSTableDef::EXTERNAL_FORMAT);
        hs_globals->hstogram_table->append(".HISTOGRM");
        
        *hs_globals->hsintval_table = hs_globals->objDef->getCatalogLoc(HSTableDef::EXTERNAL_FORMAT);
        hs_globals->hsintval_table->append(".HISTINTS");        

        // RESET CQDS:
        HSFuncExecQuery("CONTROL QUERY DEFAULT DETAILED_STATISTICS RESET");
        HSFuncExecQuery("CONTROL QUERY DEFAULT ALLOW_DP2_ROW_SAMPLING RESET");
        HSFuncExecQuery("CONTROL QUERY DEFAULT POS RESET");
        HSFuncExecQuery("CONTROL QUERY DEFAULT POS_NUM_OF_PARTNS RESET");
        // LCOV_EXCL_STOP
      }
  
    return 0;
  }