示例#1
0
void CatBuilder::catalogTask() {
    qDebug() << "CatBuilder task starting: " << (int)this;
    mp_userItems = new QList<CatItem>;
    mp_extension_results = new QList<CatItem>;
    mp_timelyItems = new QList<CatItem>;
    gMainWidget->fillBuilderInfo(this);

    Q_ASSERT(cat);
    Q_ASSERT(plugins_ptr);
    QList<CatItem> insertList;
    //bool success=false;
    SearchInfo inf;
    inf.m_extensionType = m_extensionType;
    switch (m_extensionType) {
//        case LOAD:
//            success = plugins_ptr->loadCatalogs(&(insertList));
//            if(!success) {
//                plugins_ptr->getCatalogs(&(insertList));
//            }
//            break;
    case UserEvent::CATALOGUE_LOAD:
        plugins_ptr->getCatalogs(&(insertList));
        break;
    case UserEvent::CATALOGUE_EXTEND:
        doExtension(&insertList);
        break;
    case UserEvent::BACKGROUND_SEARCH:
    default:
    {
        inf.m_userKeys = this->m_userKeys;
        inf.m_keyWords = this->m_keywords;
        inf.itemListPtr = (mp_userItems);
        plugins_ptr->backgroundSearch(&inf, &(insertList));
    }
    break;

    }
    QList<CatItem> mergedItems = cat->indexItemList(&insertList);
    mp_extension_results->clear();
    for(int i=0; i<mergedItems.count(); i++) {
        CatItem it = mergedItems[i];
        if(it.getIsTimeDependant())
        {
            mp_timelyItems->append(mergedItems[i]);
        }
        if(it.getMatchType() == CatItem::USER_KEYWORD) {
            setShown(it, UserEvent::KEYS_TYPE);
            continue;
        }
        mp_extension_results->append(it);

        //plugins_ptr->itemLoading(&it,UserEvent::JUST_FOUND);
    }
    QList<CatItem> res;
    inf.itemListPtr = &mergedItems;
    qDebug() << "give plugins another go at found items";
    plugins_ptr->itemsLoading(&inf,&res);
    res = cat->indexItemList(&res);
    mergedItems.append(res);
    mp_extension_results->clear();
    for(int i=0; i<mergedItems.count(); i++) {
        mp_extension_results->append(mergedItems[i]);
    }

    if(UserEvent::BACKGROUND_SEARCH == m_extensionType) {
        //emit backgroundSearchDone(this,m_userKeys);
        gMainWidget->backgroundSearchDone(this,m_userKeys);

        qDebug() << "search done for: " << (int)this;
    } else if( UserEvent::STANDARD_UPDATE== m_extensionType ||
               UserEvent::CATALOGUE_EXTEND== m_extensionType ||
               UserEvent::CATALOGUE_LOAD== m_extensionType ||
               UserEvent::CATALOGUE_SAVE== m_extensionType ) {
        //emit catalogFinished(this);
        gMainWidget->catalogBuilt(this);
        qDebug() << "catabuilt for: " << (int)this;
    }
    qDebug() << "run done for: " << (int)this;
    emit finished();

}
示例#2
0
文件: gpio.c 项目: LeMaker/WiringLMK
int main (int argc, char *argv [])
{
    int i ;
    int model, rev, mem, maker, overVolted ;

    if (getenv ("WIRINGPI_DEBUG") != NULL)
    {
        printf ("gpio: wiringPi debug mode enabled\n") ;
        wiringPiDebug = TRUE ;
    }

    if (argc == 1)
    {
        fprintf (stderr, "%s\n", usage) ;
        return 1 ;
    }

    // Help

    if (strcasecmp (argv [1], "-h") == 0)
    {
        printf ("%s: %s\n", argv [0], usage) ;
        return 0 ;
    }

    // Sort of a special:

    if (strcmp (argv [1], "-R") == 0)
    {
        printf ("%d\n", piBoardRev ()) ;
        return 0 ;
    }

    // Version & Warranty

    if (strcmp (argv [1], "-V") == 0)
    {
        printf ("%d\n", piBoardRev ()) ;
        return 0 ;
    }

    if (strcmp (argv [1], "-v") == 0)
    {
        printf ("gpio version: %s\n", VERSION) ;
        printf ("Copyright (c) 2012-2014 Gordon Henderson\n") ;
        printf ("This is free software with ABSOLUTELY NO WARRANTY.\n") ;
        printf ("For details type: %s -warranty\n", argv [0]) ;
        printf ("\n") ;
        piBoardId (&model, &rev, &mem, &maker, &overVolted) ;
        if (model == PI_MODEL_UNKNOWN)
        {
            printf ("Your Raspberry Pi has an unknown model type. Please report this to\n") ;
            printf ("    [email protected]\n") ;
            printf ("with a copy of your /proc/cpuinfo if possible\n") ;
        }
        else
        {
            printf ("Banana Pro Details:\n") ;
            printf ("  Type: %s, Revision: %s, Memory: %dMB, Maker: %s %s\n",
                    piModelNames [model], piRevisionNames [rev], mem, piMakerNames [maker], overVolted ? "[OV]" : "") ;
        }
        return 0 ;
    }

    if (strcasecmp (argv [1], "-warranty") == 0)
    {
        printf ("gpio version: %s\n", VERSION) ;
        printf ("Copyright (c) 2012-2014 Gordon Henderson\n") ;
        printf ("\n") ;
        printf ("    This program is free software; you can redistribute it and/or modify\n") ;
        printf ("    it under the terms of the GNU Leser General Public License as published\n") ;
        printf ("    by the Free Software Foundation, either version 3 of the License, or\n") ;
        printf ("    (at your option) any later version.\n") ;
        printf ("\n") ;
        printf ("    This program is distributed in the hope that it will be useful,\n") ;
        printf ("    but WITHOUT ANY WARRANTY; without even the implied warranty of\n") ;
        printf ("    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n") ;
        printf ("    GNU Lesser General Public License for more details.\n") ;
        printf ("\n") ;
        printf ("    You should have received a copy of the GNU Lesser General Public License\n") ;
        printf ("    along with this program. If not, see <http://www.gnu.org/licenses/>.\n") ;
        printf ("\n") ;
        return 0 ;
    }

    if (geteuid () != 0)
    {
        fprintf (stderr, "%s: Must be root to run. Program should be suid root. This is an error.\n", argv [0]) ;
        return 1 ;
    }

    // Initial test for /sys/class/gpio operations:

    /**/ if (strcasecmp (argv [1], "exports"    ) == 0)
    {
        doExports     (argc, argv) ;
        return 0 ;
    }
    else if (strcasecmp (argv [1], "export"     ) == 0)
    {
        doExport      (argc, argv) ;
        return 0 ;
    }
    else if (strcasecmp (argv [1], "edge"       ) == 0)
    {
        doEdge        (argc, argv) ;
        return 0 ;
    }
    else if (strcasecmp (argv [1], "unexport"   ) == 0)
    {
        doUnexport    (argc, argv) ;
        return 0 ;
    }
    else if (strcasecmp (argv [1], "unexportall") == 0)
    {
        doUnexportall (argv [0]) ;
        return 0 ;
    }

    // Check for load command:

    if (strcasecmp (argv [1], "load" ) == 0)
    {
        doLoad     (argc, argv) ;
        return 0 ;
    }


    // Check for -g argument

    if (strcasecmp (argv [1], "-g") == 0)
    {
        wiringPiSetupGpio () ;

        for (i = 2 ; i < argc ; ++i)
            argv [i - 1] = argv [i] ;
        --argc ;
        wpMode = WPI_MODE_GPIO ;
    }

    // Check for -1 argument

    else if (strcasecmp (argv [1], "-1") == 0)
    {
        wiringPiSetupPhys () ;

        for (i = 2 ; i < argc ; ++i)
            argv [i - 1] = argv [i] ;
        --argc ;
        wpMode = WPI_MODE_PHYS ;
    }

    // Default to wiringPi mode

    else
    {
        wiringPiSetup () ;
        wpMode = WPI_MODE_PINS ;
    }

    // Check for -x argument to load in a new extension

    if (strcasecmp (argv [1], "-x") == 0)
    {
        if (argc < 3)
        {
            fprintf (stderr, "%s: -x missing extension specification.\n", argv [0]) ;
            exit (EXIT_FAILURE) ;
        }

        if (!doExtension (argv [0], argv [2]))	// Prints its own error messages
            exit (EXIT_FAILURE) ;

        for (i = 3 ; i < argc ; ++i)
            argv [i - 2] = argv [i] ;
        argc -= 2 ;
    }

    if (argc <= 1)
    {
        fprintf (stderr, "%s: no command given\n", argv [0]) ;
        exit (EXIT_FAILURE) ;
    }

    // Core wiringPi functions

    /**/ if (strcasecmp (argv [1], "mode"   ) == 0) doMode      (argc, argv) ;
    else if (strcasecmp (argv [1], "read"   ) == 0) doRead      (argc, argv) ;
    else if (strcasecmp (argv [1], "write"  ) == 0) doWrite     (argc, argv) ;
    else if (strcasecmp (argv [1], "pwm"    ) == 0) doPwm       (argc, argv) ;
    else if (strcasecmp (argv [1], "awrite" ) == 0) doAwrite    (argc, argv) ;
    else if (strcasecmp (argv [1], "aread"  ) == 0) doAread     (argc, argv) ;

    // GPIO Nicies

    else if (strcasecmp (argv [1], "toggle" ) == 0) doToggle    (argc, argv) ;

    // Pi Specifics

    else if (strcasecmp (argv [1], "pwm-bal"  ) == 0) doPwmMode    (PWM_MODE_BAL) ;
    else if (strcasecmp (argv [1], "pwm-ms"   ) == 0) doPwmMode    (PWM_MODE_MS) ;
    else if (strcasecmp (argv [1], "pwmr"     ) == 0) doPwmRange   (argc, argv) ;
    else if (strcasecmp (argv [1], "pwmc"     ) == 0) doPwmClock   (argc, argv) ;
    else if (strcasecmp (argv [1], "pwmTone"  ) == 0) doPwmTone    (argc, argv) ;
    else if (strcasecmp (argv [1], "usbp"     ) == 0) doUsbP       (argc, argv) ;
    else if (strcasecmp (argv [1], "readall"  ) == 0) doReadall    () ;
    else if (strcasecmp (argv [1], "nreadall" ) == 0) doReadall    () ;
    else if (strcasecmp (argv [1], "pins"     ) == 0) doPins       () ;
    else if (strcasecmp (argv [1], "i2cdetect") == 0) doI2Cdetect  (argc, argv) ;
    else if (strcasecmp (argv [1], "i2cd"     ) == 0) doI2Cdetect  (argc, argv) ;
    else if (strcasecmp (argv [1], "reset"    ) == 0) doReset      (argv [0]) ;
    else if (strcasecmp (argv [1], "wb"       ) == 0) doWriteByte  (argc, argv) ;
    else
    {
        fprintf (stderr, "%s: Unknown command: %s.\n", argv [0], argv [1]) ;
        exit (EXIT_FAILURE) ;
    }
    return 0 ;
}
int main (int argc, char *argv [])
{
  int i ;

  if (getenv ("WIRINGPI_DEBUG") != NULL)
  {
    printf ("gpio: wiringPi debug mode enabled\n") ;
    wiringPiDebug = TRUE ;
  }

  if (argc == 1)
  {
    fprintf (stderr, "%s\n", usage) ;
    return 1 ;
  }

// Help

  if (strcasecmp (argv [1], "-h") == 0)
  {
    printf ("%s: %s\n", argv [0], usage) ;
    return 0 ;
  }

// Sort of a special:

  if (strcmp (argv [1], "-R") == 0)
  {
    printf ("%d\n", piBoardRev ()) ;
    return 0 ;
  }

// Version & Warranty

  if (strcmp (argv [1], "-V") == 0)
  {
    printf ("%d\n", piBoardRev ()) ;
    return 0 ;
  }

  if (strcmp (argv [1], "-v") == 0)
  {
    printf ("gpio version: %s\n", VERSION) ;
    printf ("Copyright (c) 2012-2013 Gordon Henderson\n") ;
    printf ("This is free software with ABSOLUTELY NO WARRANTY.\n") ;
    printf ("For details type: %s -warranty\n", argv [0]) ;
    printf ("\n") ;
    printf ("This Raspberry Pi is a revision %d board.\n", piBoardRev ()) ;
    return 0 ;
  }

  if (strcasecmp (argv [1], "-warranty") == 0)
  {
    printf ("gpio version: %s\n", VERSION) ;
    printf ("Copyright (c) 2012-2013 Gordon Henderson\n") ;
    printf ("\n") ;
    printf ("    This program is free software; you can redistribute it and/or modify\n") ;
    printf ("    it under the terms of the GNU Leser General Public License as published\n") ;
    printf ("    by the Free Software Foundation, either version 3 of the License, or\n") ;
    printf ("    (at your option) any later version.\n") ;
    printf ("\n") ;
    printf ("    This program is distributed in the hope that it will be useful,\n") ;
    printf ("    but WITHOUT ANY WARRANTY; without even the implied warranty of\n") ;
    printf ("    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n") ;
    printf ("    GNU Lesser General Public License for more details.\n") ;
    printf ("\n") ;
    printf ("    You should have received a copy of the GNU Lesser General Public License\n") ;
    printf ("    along with this program. If not, see <http://www.gnu.org/licenses/>.\n") ;
    printf ("\n") ;
    return 0 ;
  }

  if (geteuid () != 0)
  {
    fprintf (stderr, "%s: Must be root to run. Program should be suid root. This is an error.\n", argv [0]) ;
    return 1 ;
  }

// Initial test for /sys/class/gpio operations:

  /**/ if (strcasecmp (argv [1], "exports"    ) == 0)	{ doExports     (argc, argv) ;	return 0 ; }
  else if (strcasecmp (argv [1], "export"     ) == 0)	{ doExport      (argc, argv) ;	return 0 ; }
  else if (strcasecmp (argv [1], "edge"       ) == 0)	{ doEdge        (argc, argv) ;	return 0 ; }
  else if (strcasecmp (argv [1], "unexport"   ) == 0)	{ doUnexport    (argc, argv) ;	return 0 ; }
  else if (strcasecmp (argv [1], "unexportall") == 0)	{ doUnexportall (argv [0]) ;	return 0 ; }

// Check for load command:

  if (strcasecmp (argv [1], "load" ) == 0)	{ doLoad     (argc, argv) ; return 0 ; }

// Gertboard commands

  if (strcasecmp (argv [1], "gbr" ) == 0)	{ doGbr (argc, argv) ; return 0 ; }
  if (strcasecmp (argv [1], "gbw" ) == 0)	{ doGbw (argc, argv) ; return 0 ; }

// Check for -g argument

  /**/ if (strcasecmp (argv [1], "-g") == 0)
  {
    wiringPiSetupGpio () ;

    for (i = 2 ; i < argc ; ++i)
      argv [i - 1] = argv [i] ;
    --argc ;
    wpMode = WPI_MODE_GPIO ;
  }

// Check for -1 argument

  else if (strcasecmp (argv [1], "-1") == 0)
  {
    wiringPiSetupPhys () ;

    for (i = 2 ; i < argc ; ++i)
      argv [i - 1] = argv [i] ;
    --argc ;
    wpMode = WPI_MODE_PHYS ;
  }

// Check for -p argument for PiFace

  else if (strcasecmp (argv [1], "-p") == 0)
  {
    piFaceSetup (200) ;

    for (i = 2 ; i < argc ; ++i)
      argv [i - 1] = argv [i] ;
    --argc ;
    wpMode = WPI_MODE_PIFACE ;
  }

// Default to wiringPi mode

  else
  {
    wiringPiSetup () ;
    wpMode = WPI_MODE_PINS ;
  }

// Check for -x argument to load in a new extension

  if (strcasecmp (argv [1], "-x") == 0)
  {
    if (argc < 3)
    {
      fprintf (stderr, "%s: -x missing extension specification.\n", argv [0]) ;
      exit (EXIT_FAILURE) ;
    }

    if (!doExtension (argv [0], argv [2]))	// Prints its own error messages
      exit (EXIT_FAILURE) ;

    for (i = 3 ; i < argc ; ++i)
      argv [i - 2] = argv [i] ;
    argc -= 2 ;
  }

  if (argc <= 1)
  {
    fprintf (stderr, "%s: no command given\n", argv [0]) ;
    exit (EXIT_FAILURE) ;
  }

// Core wiringPi functions

  /**/ if (strcasecmp (argv [1], "mode"   ) == 0) doMode      (argc, argv) ;
  else if (strcasecmp (argv [1], "read"   ) == 0) doRead      (argc, argv) ;
  else if (strcasecmp (argv [1], "write"  ) == 0) doWrite     (argc, argv) ;
  else if (strcasecmp (argv [1], "pwm"    ) == 0) doPwm       (argc, argv) ;
  else if (strcasecmp (argv [1], "awrite" ) == 0) doAwrite    (argc, argv) ;
  else if (strcasecmp (argv [1], "aread"  ) == 0) doAread     (argc, argv) ;

// GPIO Nicies

  else if (strcasecmp (argv [1], "toggle" ) == 0) doToggle    (argc, argv) ;

// Pi Specifics

  else if (strcasecmp (argv [1], "pwm-bal"  ) == 0) doPwmMode   (PWM_MODE_BAL) ;
  else if (strcasecmp (argv [1], "pwm-ms"   ) == 0) doPwmMode   (PWM_MODE_MS) ;
  else if (strcasecmp (argv [1], "pwmr"     ) == 0) doPwmRange  (argc, argv) ;
  else if (strcasecmp (argv [1], "pwmc"     ) == 0) doPwmClock  (argc, argv) ;
  else if (strcasecmp (argv [1], "drive"    ) == 0) doPadDrive  (argc, argv) ;
  else if (strcasecmp (argv [1], "readall"  ) == 0) doReadall   () ;
  else if (strcasecmp (argv [1], "i2cdetect") == 0) doI2Cdetect (argc, argv) ;
  else if (strcasecmp (argv [1], "i2cd"     ) == 0) doI2Cdetect (argc, argv) ;
  else if (strcasecmp (argv [1], "reset"    ) == 0) doReset     (argv [0]) ;
  else if (strcasecmp (argv [1], "wb"       ) == 0) doWriteByte (argc, argv) ;
  else if (strcasecmp (argv [1], "clock"    ) == 0) doClock     (argc, argv) ;
  else if (strcasecmp (argv [1], "wfi"      ) == 0) doWfi       (argc, argv) ;
  else
  {
    fprintf (stderr, "%s: Unknown command: %s.\n", argv [0], argv [1]) ;
    exit (EXIT_FAILURE) ;
  }
  return 0 ;
}