Ejemplo n.º 1
0
/* @bug 4113018
 * MessageFormat.applyPattern works wrong with illegal patterns.
 */
void MessageFormatRegressionTest::Test4113018()
{
    UnicodeString originalPattern("initial pattern");
    UErrorCode status = U_ZERO_ERROR;
    MessageFormat *mf = new MessageFormat(originalPattern, status);
    failure(status, "new messageFormat");
    UnicodeString illegalPattern("format: {0, xxxYYY}");
    UnicodeString pat;
    logln("pattern before: \"" + mf->toPattern(pat) + "\"");
    logln("illegal pattern: \"" + illegalPattern + "\"");
    //try {
    mf->applyPattern(illegalPattern, status);
    if( ! U_FAILURE(status))
        errln("Should have thrown IllegalArgumentException for pattern : " + illegalPattern);
    /*} catch (IllegalArgumentException e) {
        if (!originalPattern.equals(mf.toPattern()))
            errln("pattern after: \"" + mf.toPattern() + "\"");
    }*/
    delete mf;
}
Ejemplo n.º 2
0
void MessageFormatRegressionTest::Test4104976()
{
    double limits [] = {1, 20};
    UnicodeString formats [] = {
        UnicodeString("xyz"),
        UnicodeString("abc")
    };
    int32_t formats_length = (int32_t)(sizeof(formats)/sizeof(formats[0]));
    UErrorCode status = U_ZERO_ERROR;
    ChoiceFormat *cf = new ChoiceFormat(limits, formats, formats_length);
    failure(status, "new ChoiceFormat");
    //try {
    log("Compares to null is always false, returned : ");
    logln(cf == NULL ? "TRUE" : "FALSE");
    /*} catch (Exception foo) {
        errln("ChoiceFormat.equals(null) throws exception.");
    }*/

    delete cf;
}
Ejemplo n.º 3
0
/*
 * Use elf_xlatetom() to convert the bytes in buf from their
 * in-file representation to their in-memory representation.
 *
 * Returns True(1) for success. On failure, an error message is printed
 * and False(0) is returned.
 */
static int
xlate_data(FSTATE *fstate, void *buf, size_t nbyte, Elf_Type xlate_type)
{
	Elf_Data	data;

	data.d_type = xlate_type;
	data.d_size = nbyte;
	data.d_off = 0;
	data.d_align = 0;
	data.d_version = fstate->ehdr->e_version;
	data.d_buf = buf;

	if (elf_xlatetom(&data, &data,
	    fstate->ehdr->e_ident[EI_DATA]) == NULL) {
		failure(fstate->file, MSG_ORIG(MSG_ELF_XLATETOM));
		return (0);
	}

	return (1);
}
Ejemplo n.º 4
0
int SYM_verifyFunction(SymbolTable* st, AST* function){
	// Symbol* symbol = ST_get(st, id, scope);
	// if(symbol)
	// 	return failure("function already declared", function);
	char* id;
	int function_return = NULL; //type function will return
	int size;
	for(AST* child = function->first_child; child; child = child->next){
		switch(child->type){
			case AST_INT:
				function_return = SYM_INT;
				break;
			case AST_FLOAT:
				function_return = SYM_FLOAT;
				break;
			case AST_CHAR:
				function_return = SYM_CHAR;
				break;
			case AST_VOID:
				function_return = SYM_VOID;
				break;
			case AST_PARAMS:
				SYM_verifyParams(st, child);
				break;
			case AST_ID:
				id = child->val.sval;
				Symbol* symbol = ST_get(st, id, scope);
				if(symbol){
					return failure("function already declared", function, id);
				}
				Symbol* sym = SYM_new(id, SYM_FUNC, scope, 0, function_return);
				last_function = sym;
				ST_addNewSymbol(st, sym);
				break;
			case AST_BLOCK:
				SYM_verifyBlock(st, child);
				break;
		}
	}//end for
	return 0;	
}
Ejemplo n.º 5
0
static void verifyEmpty(void)
{
	struct archive_entry *ae;
	struct archive *a;

	assert((a = archive_read_new()) != NULL);
	assertA(0 == archive_read_support_compression_all(a));
	assertA(0 == archive_read_support_format_all(a));
	assertA(0 == archive_read_open_memory(a, archiveEmpty, 512));
	assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
	assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_NONE);
	failure("512 zero bytes should be recognized as a tar archive.");
	assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR);

	assert(0 == archive_read_close(a));
#if ARCHIVE_API_VERSION > 1
	assert(0 == archive_read_finish(a));
#else
	archive_read_finish(a);
#endif
}
Ejemplo n.º 6
0
    void ensure_close(const char* msg, const T& actual, const T& expected, const U& tolerance)
    {
        typedef detail::fpt_traits<U> Traits;

        typename Traits::Result fraction
            = Traits::div(Traits::abs(static_cast<typename Traits::Result>(tolerance)),
                static_cast<typename Traits::Result>(100));
        if(!detail::check_tolerance(actual, expected, fraction)){
            std::ostringstream ss;
            ss << (msg ? msg : "")
               << (msg ? ": " : "")
               << "expected `"
               << expected
               << "` and actual `"
               << actual
               << "` differ more than "
               << tolerance
               << "%";
            throw failure(ss.str().c_str());
        }
    }
Ejemplo n.º 7
0
void TestPeerLogicAsyncServer::on_write (error_code const& ec, std::size_t bytes_transferred)
{
    if (aborted (ec) || failure (error (ec)))
        return finished ();

    if (unexpected (bytes_transferred == 7, error ()))
        return finished ();

    if (socket ().needs_handshake ())
    {
        socket ().async_shutdown (boost::bind (&TestPeerLogicAsyncServer::on_shutdown, this,
            boost::asio::placeholders::error));
    }
    else
    {
        // on_shutdown will call finished ()
        // we need another instance of ec so we can call on_shutdown()
        error_code ec;
        on_shutdown (socket ().shutdown (Socket::shutdown_both, ec));
    }
}
Ejemplo n.º 8
0
void unit_test::run( std::map<std::string,std::function<void(void)>>::iterator &it )
{
	precondition( it != _tests.end(), "invalid test" );

	// Make sure we are not already running...
	const std::string &n = it->first;
	if ( std::find( _running.begin(), _running.end(), n ) == _running.end() )
		_running.emplace_back( n );
	else
		throw_runtime( "recursive tests not allowed: {0}", infix_separated( ", ", _running ) );
	on_scope_exit { _running.erase( std::remove( _running.begin(), _running.end(), n ), _running.end() ); };

	// Already completed
	if ( _success.find( n ) != _success.end() )
		return;
	if ( _failure.find( n ) != _failure.end() )
		throw_runtime( "test '{0}' has failed", n );

	// Run the test
	size_t failures = _failure.size();
	try
	{
		it->second();
	}
	catch ( std::exception &e )
	{
		std::stringstream tmp;
		base::print_exception( tmp, e );
		std::vector<std::string> lines;
		base::split( tmp.str(), '\n', std::back_inserter( lines ), true );
		for ( auto &l: lines )
			message( l );
		failure( std::string( e.what() ) );
	}

	if ( failures != _failure.size() )
		_failure.insert( n );
	else
		_success.insert( n );
}
/*
 * All of the sample files have the same contents; they're just
 * compressed in different ways.
 */
static void
compat_bzip2(const char *name)
{
	const char *n[7] = { "f1", "f2", "f3", "d1/f1", "d1/f2", "d1/f3", NULL };
	struct archive_entry *ae;
	struct archive *a;
	int i;

	assert((a = archive_read_new()) != NULL);
	if (ARCHIVE_OK != archive_read_support_filter_bzip2(a)) {
		skipping("Unsupported bzip2");
		return;
	}
	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
	extract_reference_file(name);
	assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, name, 2));

	/* Read entries, match up names with list above. */
	for (i = 0; i < 6; ++i) {
		failure("Could not read file %d (%s) from %s", i, n[i], name);
		assertEqualIntA(a, ARCHIVE_OK,
		    archive_read_next_header(a, &ae));
		assertEqualString(n[i], archive_entry_pathname(ae));
	}

	/* Verify the end-of-archive. */
	assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));

	/* Verify that the format detection worked. */
	assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_BZIP2);
	assertEqualString(archive_compression_name(a), "bzip2");
	assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_USTAR);

	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
	assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_BZIP2);
	assertEqualString(archive_compression_name(a), "bzip2");
	assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_USTAR);

	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
}
Ejemplo n.º 10
0
void MessageFormatRegressionTest::TestChoicePatternQuote() 
{
    UnicodeString DATA [] = {
        // Pattern                  0 value           1 value
        // {sfb} hacked - changed \u2264 to = (copied from Character Map)
        (UnicodeString)"0#can''t|1#can",           (UnicodeString)"can't",          (UnicodeString)"can",
        (UnicodeString)"0#'pound(#)=''#'''|1#xyz", (UnicodeString)"pound(#)='#'",   (UnicodeString)"xyz",
        (UnicodeString)"0#'1<2 | 1=1'|1#''",  (UnicodeString)"1<2 | 1=1", (UnicodeString)"'",
    };
    for (int i=0; i<9; i+=3) {
        //try {
            UErrorCode status = U_ZERO_ERROR;
            ChoiceFormat *cf = new ChoiceFormat(DATA[i], status);
            failure(status, "new ChoiceFormat");
            for (int j=0; j<=1; ++j) {
                UnicodeString out;
                FieldPosition pos(FieldPosition::DONT_CARE);
                out = cf->format((double)j, out, pos);
                if (out != DATA[i+1+j])
                    errln("Fail: Pattern \"" + DATA[i] + "\" x "+j+" -> " +
                          out + "; want \"" + DATA[i+1+j] + '"');
            }
            UnicodeString pat;
            pat = cf->toPattern(pat);
            UnicodeString pat2;
            ChoiceFormat *cf2 = new ChoiceFormat(pat, status);
            pat2 = cf2->toPattern(pat2);
            if (pat != pat2)
                errln("Fail: Pattern \"" + DATA[i] + "\" x toPattern -> \"" + pat + '"');
            else
                logln("Ok: Pattern \"" + DATA[i] + "\" x toPattern -> \"" + pat + '"');
        /*}
        catch (IllegalArgumentException e) {
            errln("Fail: Pattern \"" + DATA[i] + "\" -> " + e);
        }*/
    
        delete cf;
        delete cf2;
    }
}
Ejemplo n.º 11
0
static void tgprpl_xfer_recv_on_finished (struct tgl_state *TLS, void *_data, int success, const char *filename) {
  debug ("tgprpl_xfer_recv_on_finished()");
  struct tgp_xfer_send_data *data = _data;

  if (success) {
    if (!data->done) {
      debug ("purple_xfer_set_completed");
      purple_xfer_set_bytes_sent (data->xfer, purple_xfer_get_size (data->xfer));
      purple_xfer_set_completed (data->xfer, TRUE);
      purple_xfer_end (data->xfer);
    }
    
    g_unlink (purple_xfer_get_local_filename (data->xfer));
    g_rename (filename, purple_xfer_get_local_filename (data->xfer));

  } else {
    failure ("ERROR xfer failed");
  }

  data->xfer->data = NULL;
  tgprpl_xfer_free_data (data);
}
Ejemplo n.º 12
0
void YVCache::getChapter() {
    QNetworkReply* reply = dynamic_cast<QNetworkReply*>(sender());
    if (reply->error() != QNetworkReply::NoError)
        return;   //dealt with in failure()

    QByteArray ba = reply->readAll();
    delete reply;
    m_reply = 0;

    if (!ba.contains("\"human\"")) {
        failure();
        return;
    }

    QString t = "cache_"+ (s_translation->abbrev() + QString::number(s_chapIdx) + "_" + QString::number(s_bookIdx));
    QFile f(qgetenv("HOME") + "/" + t);
    f.open(QFile::WriteOnly);
    f.write(ba);
    f.close();

    QTimer::singleShot(500, this, SLOT(getNextChapter()));
}
Ejemplo n.º 13
0
piece new_piece_rh(int x, int y, bool small, bool horizontal)
{
    piece newp = NULL;
    if (small) {
        if (horizontal) {
            newp = new_piece(x, y, smallSize, thickness, horizontal, !horizontal);
        } else {
            newp = new_piece(x, y, thickness, smallSize, horizontal, !horizontal);
        }
    } else {
        if (horizontal) {
            newp = new_piece(x, y, bigSize, thickness, horizontal, !horizontal);
        } else {
            newp = new_piece(x, y, thickness, bigSize, horizontal, !horizontal);
        }
    }
    if (!newp) {
        failure("new_piece_rh alloc newp");
        return NULL;
    }
    return newp;
}
Ejemplo n.º 14
0
Archivo: yusb.c Proyecto: emmt/yusb
void Y_usb_summary(int argc)
{
  ssize_t i;
  libusb_device_handle* handle;

  load_device_list();
  for (i = 0; i < dev_count; ++i) {
    int code;
    struct libusb_device_descriptor desc;
    libusb_device* dev = dev_list[i];
    uint8_t bus_number = libusb_get_bus_number(dev);
    uint8_t port_number = libusb_get_port_number(dev);
    uint8_t device_address = libusb_get_device_address(dev);
    fprintf(stdout, "USB Device %ld:\n", (long)i);
    fprintf(stdout, "  Bus Number ---------> %d\n", (int)bus_number);
    fprintf(stdout, "  Port Number --------> %d\n", (int)port_number);
    fprintf(stdout, "  Device Address -----> %d\n", (int)device_address);
    code = libusb_get_device_descriptor(dev, &desc);
    if (code != 0) {
      failure(NULL, code);
    }
    fprintf(stdout, "  Vendor ID ----------> 0x%04x\n",
            (unsigned int)desc.idVendor);
    fprintf(stdout, "  Product ID ---------> 0x%04x\n",
            (unsigned int)desc.idProduct);
    code = libusb_open(dev, &handle);
    if (code == 0) {
      fprintf(stdout, "  Manufacturer -------> %s\n",
              get_string(handle, desc.iManufacturer));
      fprintf(stdout, "  Product ------------> %s\n",
              get_string(handle, desc.idProduct));
      fprintf(stdout, "  Serial Number ------> %s\n",
              get_string(handle, desc.iSerialNumber));
      libusb_close(handle);
    }
  }
  free_dev_list();
  ypush_nil();
}
Ejemplo n.º 15
0
/**
 * @bug 4109314
 */
void TimeZoneRegressionTest:: Test4109314() {
    UErrorCode status = U_ZERO_ERROR;
    GregorianCalendar *testCal = (GregorianCalendar*)Calendar::createInstance(status); 
    if(U_FAILURE(status)) {
      dataerrln("Error creating calendar %s", u_errorName(status));
      delete testCal;
      return;
    }
    failure(status, "Calendar::createInstance");
    TimeZone *PST = TimeZone::createTimeZone("PST");
    /*Object[] testData = {
        PST, new Date(98,Calendar.APRIL,4,22,0), new Date(98, Calendar.APRIL, 5,6,0),
        PST, new Date(98,Calendar.OCTOBER,24,22,0), new Date(98,Calendar.OCTOBER,25,6,0),
    };*/
    UDate testData [] = {
        CalendarRegressionTest::makeDate(98,UCAL_APRIL,4,22,0),    
        CalendarRegressionTest::makeDate(98, UCAL_APRIL,5,6,0),
        CalendarRegressionTest::makeDate(98,UCAL_OCTOBER,24,22,0), 
        CalendarRegressionTest::makeDate(98,UCAL_OCTOBER,25,6,0)
    };
    UBool pass = TRUE;
    for (int32_t i = 0; i < 4; i+=2) {
        //testCal->setTimeZone((TimeZone) testData[i]);
        testCal->setTimeZone(*PST);
        UDate t        = testData[i];
        UDate end    = testData[i+1];
        while(testCal->getTime(status) < end) { 
            testCal->setTime(t, status);
            if ( ! checkCalendar314(testCal, PST))
                pass = FALSE;
            t += 60*60*1000.0;
        } 
    }
    if ( ! pass) 
        errln("Fail: TZ API inconsistent");

    delete testCal;
    delete PST;
} 
Ejemplo n.º 16
0
STATIC WORD IoctlQueblk(rqptr rp, ddt * pddt)
{
  UNREFERENCED_PARAMETER(pddt);

#ifdef WITHFAT32
  if (rp->r_cat == 8 || rp->r_cat == 0x48)
#else
  if (rp->r_cat == 8)
#endif
  {
    switch (rp->r_fun)
    {
    case 0x46:
    case 0x47:
    case 0x60:
    case 0x66:
    case 0x67:
      return S_DONE;
    }
  }
  return failure(E_CMD);
}
Ejemplo n.º 17
0
static void tgprpl_xfer_recv_init (PurpleXfer *X) {
  debug ("tgprpl_xfer_recv_init");
  struct tgp_xfer_send_data *data = X->data;
  struct tgl_state *TLS = data->conn->TLS;
  struct tgl_message *M = data->msg;
  struct tgl_document *D = M->media.document;
  tgl_peer_t *P = NULL;
  
  purple_xfer_start (X, -1, NULL, 0);
  const char *who = purple_xfer_get_remote_user (X);
  P = find_peer_by_name (TLS, who);
  if (P) {
    switch (M->media.type) {
      case tgl_message_media_document:
        tgl_do_load_document (TLS, D, tgprpl_xfer_recv_on_finished, data);
        break;
        
      case tgl_message_media_document_encr:
        tgl_do_load_encr_document (TLS, M->media.encr_document,
                                   tgprpl_xfer_recv_on_finished, data);
        break;
      
      case tgl_message_media_audio:
        tgl_do_load_audio (TLS, D, tgprpl_xfer_recv_on_finished, data);
        break;
        
      case tgl_message_media_video:
        tgl_do_load_video (TLS, D, tgprpl_xfer_recv_on_finished, data);
        break;

      default:
        failure ("Unknown message media type: %d, XFER not possible.", M->media.type);
        break;
    }
  } else {
    warning ("User not found, not downloading...");
  }
  data->timer = purple_timeout_add (100, tgprpl_xfer_upload_progress, X);
}
Ejemplo n.º 18
0
/*
 * All of the sample files have the same contents; they're just
 * compressed in different ways.
 */
static void
compat_lzma(const char *name)
{
	const char *n[7] = { "f1", "f2", "f3", "d1/f1", "d1/f2", "d1/f3", NULL };
	struct archive_entry *ae;
	struct archive *a;
	int i, r;

	assert((a = archive_read_new()) != NULL);
	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
	r = archive_read_support_filter_lzma(a);
	if (r == ARCHIVE_WARN) {
		skipping("lzma reading not fully supported on this platform");
		assertEqualInt(ARCHIVE_OK, archive_read_free(a));
		return;
	}
	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
	extract_reference_file(name);
	assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, name, 2));

	/* Read entries, match up names with list above. */
	for (i = 0; i < 6; ++i) {
		failure("Could not read file %d (%s) from %s", i, n[i], name);
		assertEqualIntA(a, ARCHIVE_OK,
		    archive_read_next_header(a, &ae));
		assertEqualString(n[i], archive_entry_pathname(ae));
	}

	/* Verify the end-of-archive. */
	assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));

	/* Verify that the format detection worked. */
	assertEqualInt(archive_filter_code(a, 0), ARCHIVE_FILTER_LZMA);
	assertEqualString(archive_filter_name(a, 0), "lzma");
	assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_USTAR);

	assertEqualInt(ARCHIVE_OK, archive_read_close(a));
	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
}
Ejemplo n.º 19
0
void ClipperNetwork::convertToQRCode(QString text)
{
    QUrlQuery requestQuery;
    requestQuery.addQueryItem("d", QUrl::toPercentEncoding(text));
    QUrl requestUrl(QR_CODE_URL);
    requestUrl.setQuery(requestQuery);

    QNetworkReply *networkRequest = network->get(QNetworkRequest(requestUrl));

    connect(networkRequest, &QNetworkReply::finished, [networkRequest, this]() {
        if (networkRequest->error() == QNetworkReply::NoError)
        {
            std::shared_ptr<QPixmap> qrCode(new QPixmap());
            qrCode->loadFromData(networkRequest->readAll());
            emit qrCodeReady(qrCode);
        }
        else
            emit failure(networkRequest->errorString());

        networkRequest->deleteLater();
    });
}
Ejemplo n.º 20
0
static gboolean tgprpl_xfer_upload_progress (gpointer _data) {
  PurpleXfer *X = _data;
  struct tgp_xfer_send_data *data = X->data;
  connection_data *conn = data->conn;
  
  PurpleXferType type = purple_xfer_get_type(X);
  switch (type) {
    case PURPLE_XFER_SEND:
      purple_xfer_set_size (X, conn->TLS->cur_uploading_bytes);
      purple_xfer_set_bytes_sent (X, conn->TLS->cur_uploaded_bytes);
      purple_xfer_update_progress (X);
      
      debug ("PURPLE_XFER_SEND progress %d / %d", conn->TLS->cur_uploaded_bytes, conn->TLS->cur_uploading_bytes);
      if (conn->TLS->cur_uploaded_bytes == conn->TLS->cur_uploading_bytes) {
        data->timer = 0;
        return FALSE;
      }
      break;
      
    case PURPLE_XFER_RECEIVE:
      purple_xfer_set_size (X, conn->TLS->cur_downloading_bytes);
      purple_xfer_set_bytes_sent (X, conn->TLS->cur_downloaded_bytes);
      purple_xfer_update_progress (X);
      
      debug ("PURPLE_XFER_RECEIVE progress %d / %d", conn->TLS->cur_downloaded_bytes, conn->TLS->cur_downloading_bytes);
      if (conn->TLS->cur_downloading_bytes == conn->TLS->cur_downloaded_bytes) {
        data->timer = 0;
        return FALSE;
      }
      break;
      
    default:
    case PURPLE_XFER_UNKNOWN:
      failure ("ERROR: tgprpl_xfer_upload_progress xfer type PURPLE_XFER_UNKNOWN.");
      return FALSE;
      break;
  }
  return TRUE;
}
Ejemplo n.º 21
0
void TestPeerLogicSyncServer::on_connect ()
{
    if (socket ().needs_handshake ())
    {
        if (failure (socket ().handshake (to_handshake_type (get_role ()), error ())))
            return;
    }

    {
        boost::asio::streambuf buf (5);
        std::size_t const amount = boost::asio::read_until (
            socket (), buf, "hello", error ());

        if (failure (error ()))
            return;

        if (unexpected (amount == 5, error ()))
            return;

        if (unexpected (buf.size () == 5, error ()))
            return;
    }

    {
        std::size_t const amount = boost::asio::write (
            socket (), boost::asio::buffer ("goodbye", 7), error ());

        if (failure (error ()))
            return;

        if (unexpected (amount == 7, error ()))
            return;
    }

    if (socket ().needs_handshake ())
    {
        if (failure (socket ().shutdown (error ()), true))
            return;
    }

    if (failure (socket ().shutdown (Socket::shutdown_both, error ())))
        return;

    if (failure (socket ().close (error ())))
        return;
}
Ejemplo n.º 22
0
void Loader::start() {
   dgd_scopef(trace_download);

   m_state_guard.lock();
      
   if( !m_enabled || m_download_fetcher.get() != NULL ) {
      m_state_guard.unlock();
      return;
   }

   m_download_fetcher.reset( 
      new boxfish::download_fetcher(
         boost::bind(&Loader::report_progress, this, _1, _2),
         boost::bind(&Loader::report_error, this, _1)
      )
   );

   m_browser.reset( 
      new openvrml::browser( *m_download_fetcher, std::cout, std::cerr ) );

   m_browser->add_listener(*this);

   std::vector<std::string> urls,params;
   urls.push_back( QString(m_url.toEncoded()).toStdString() );
	    
   try {
      m_browser->load_url( urls, params );
   } catch( std::exception &ex ) {
      m_error_string += ex.what();
      emit failure(m_error_string);
      dgd_logger << "got exception in load_url() while loading: " 
                 << QString(m_url.toEncoded())
                 << " , reason was: " << ex.what()
                 << std::endl;
   }
   
   m_state_guard.unlock();
}
Ejemplo n.º 23
0
static int
acl_get_specific_entry(acl_t acl, acl_tag_t requested_tag_type, int requested_tag) {
	int entry_id = ACL_FIRST_ENTRY;
	acl_entry_t acl_entry;
	acl_tag_t acl_tag_type;
	
	while (1 == acl_get_entry(acl, entry_id, &acl_entry)) {
		/* After the first time... */
		entry_id = ACL_NEXT_ENTRY;

		/* If this matches, return perm mask */
		acl_get_tag_type(acl_entry, &acl_tag_type);
		if (acl_tag_type == requested_tag_type) {
			switch (acl_tag_type) {
			case ACL_USER_OBJ:
				if ((uid_t)requested_tag == *(uid_t *)(acl_get_qualifier(acl_entry))) {
					return acl_entry_get_perm(acl_entry);
				}
				break;
			case ACL_GROUP_OBJ:
				if ((gid_t)requested_tag == *(gid_t *)(acl_get_qualifier(acl_entry))) {
					return acl_entry_get_perm(acl_entry);
				}
				break;
			case ACL_USER:
			case ACL_GROUP:
			case ACL_OTHER:
				return acl_entry_get_perm(acl_entry);
			default:
				failure("Unexpected ACL tag type");
				assert(0);
			}
		}


	}
	return -1;
}
Ejemplo n.º 24
0
Archivo: yusb.c Proyecto: emmt/yusb
void Y__usb_probe_devices(int argc)
{
  struct libusb_device_descriptor desc;
  libusb_device* dev;
  long dims[3];
  int* data;
  int i, ret;

  if (argc != 1 || ! yarg_nil(0)) {
    y_error("expecting exactly one nil argument");
  }
  load_device_list();
  if (dev_count > 0) {
    dims[0] = 2;
    dims[1] = 7;
    dims[2] = dev_count;
    data = ypush_i(dims);
    for (i = 0; i < dev_count; ++i) {
      dev = dev_list[i];
      ret = libusb_get_device_descriptor(dev, &desc);
      if (ret != 0) {
        free_dev_list();
        failure("unable to get device descriptor", ret);
      }
      data[0] = libusb_get_bus_number(dev);
      data[1] = libusb_get_port_number(dev);
      data[2] = libusb_get_device_address(dev);
      data[3] = desc.idVendor;
      data[4] = desc.idProduct;
      data[5] = desc.iManufacturer;
      data[6] = desc.iSerialNumber;
      data += 7;
    }
  } else {
    ypush_nil();
  }
  free_dev_list();
}
Ejemplo n.º 25
0
void
TestSingleRemove::testRunBookError() {
    auto book = std::make_shared<com::chancho::tests::MockBook>();
    auto acc = std::make_shared<com::chancho::Account>();

    EXPECT_CALL(*book.get(),
                remove(Matcher<com::chancho::AccountPtr>(_)))
            .Times(1);

    EXPECT_CALL(*book.get(), isError())
            .Times(1)
            .WillOnce(Return(true));

    auto worker = std::make_shared<com::chancho::qml::workers::accounts::SingleRemove>(book, acc);
    // ensure that the signals are indeed fired
    QSignalSpy successSpy(worker.get(), SIGNAL(success()));
    QSignalSpy failureSpy(worker.get(), SIGNAL(failure()));

    worker->run();

    QCOMPARE(successSpy.count(), 0);
    QCOMPARE(failureSpy.count(), 1);
}
Ejemplo n.º 26
0
static void
test_sparse_whole_file_data()
{
	struct archive_entry *ae;
	int64_t offset;
	int i;

	assert((ae = archive_entry_new()) != NULL);
	archive_entry_set_size(ae, 1024*10);

	/*
	 * Add sparse block data up to the file size.
	 */
	offset = 0;
	for (i = 0; i < 10; i++) {
		archive_entry_sparse_add_entry(ae, offset, 1024);
		offset += 1024;
	}

	failure("There should be no sparse");
	assertEqualInt(0, archive_entry_sparse_count(ae));
	archive_entry_free(ae);
}
Ejemplo n.º 27
0
RefPtr<OmxPromiseLayer::OmxBufferPromise>
OmxPromiseLayer::EmptyBuffer(BufferData* aData)
{
  MOZ_ASSERT(mTaskQueue->IsCurrentThreadIn());
  LOG("buffer %p, size %lu", aData->mBuffer, aData->mBuffer->nFilledLen);

  RefPtr<OmxBufferPromise> p = aData->mPromise.Ensure(__func__);

  OMX_ERRORTYPE err = mPlatformLayer->EmptyThisBuffer(aData);

  if (err != OMX_ErrorNone) {
    OmxBufferFailureHolder failure(err, aData);
    aData->mPromise.Reject(Move(failure), __func__);
  } else {
    if (aData->mRawData) {
      mRawDatas.AppendElement(Move(aData->mRawData));
    }
    aData->mStatus = BufferData::BufferStatus::OMX_COMPONENT;
    GetBufferHolders(OMX_DirInput)->AppendElement(aData);
  }

  return p;
}
Ejemplo n.º 28
0
void Authorization::handleChangedUrl(QUrl const& newUrl)
{
    static QUrl const uAuthtorizationRedirectUrl(AUTHORIZATION_REDIRECT_URL);
    if(newUrl.matches(uAuthtorizationRedirectUrl,QUrl::RemoveFragment | QUrl::RemoveQuery))
    {
        if( newUrl.hasFragment() )
        {
            QUrlQuery query( newUrl.fragment() );

            QString accessToken = query.queryItemValue(QString("access_token"));
            QString userID = query.queryItemValue("user_id");
            emit success(accessToken,userID);
        }
        else
        {
            QUrlQuery query( newUrl.query() );
            QString error = query.queryItemValue(QString("error"));
            QString errorDescription = query.queryItemValue("eror_description");
            emit failure(error,errorDescription);
        }
        hide();
    }
}
Ejemplo n.º 29
0
void PFindSchemaElement::start()
{
    /* 1) add actions
       2) start actions
       3) wait signals */

    // Evalutate requires
    QList<PSchemaElement> childRequireSchemas = m_from.schema().requires();
    if (!childRequireSchemas.isEmpty()) {
        // there is at least one require to evaluate
        PActionGroup *evalRequireGroup = new PActionGroup(this);
        evalRequireGroup->setSingleStatusToStop(PAction::StatusFailure, PAction::StatusFailure);
        for (int i=0; i<childRequireSchemas.length(); i++) {
            // add the require evaluator for the current require to the action group
            PWrapperRequire *require = m_from.childRequire(childRequireSchemas.at(i));
            PEvalWrapperRequire *evalRequire = new PEvalWrapperRequire(require);
            evalRequireGroup->addAction(evalRequire);
            // fail if the group fails
            connect(evalRequireGroup, SIGNAL(failure(PAction::StatusType)), this, SLOT(finish(PAction::StatusType)));
        }

    }
}
Ejemplo n.º 30
0
RefPtr<MP4TrackDemuxer::SkipAccessPointPromise>
MP4TrackDemuxer::SkipToNextRandomAccessPoint(media::TimeUnit aTimeThreshold)
{
  mQueuedSample = nullptr;
  // Loop until we reach the next keyframe after the threshold.
  uint32_t parsed = 0;
  bool found = false;
  RefPtr<MediaRawData> sample;
  while (!found && (sample = mIterator->GetNext())) {
    parsed++;
    if (sample->mKeyframe && sample->mTime >= aTimeThreshold.ToMicroseconds()) {
      found = true;
      mQueuedSample = sample;
    }
  }
  SetNextKeyFrameTime();
  if (found) {
    return SkipAccessPointPromise::CreateAndResolve(parsed, __func__);
  } else {
    SkipFailureHolder failure(DemuxerFailureReason::END_OF_STREAM, parsed);
    return SkipAccessPointPromise::CreateAndReject(Move(failure), __func__);
  }
}