QtCurveSizeGrip::QtCurveSizeGrip(QtCurveClient* client): QWidget(0), client_(client) { setAttribute(Qt::WA_NoSystemBackground ); setAutoFillBackground(false); // cursor setCursor(Qt::SizeFDiagCursor); // size setFixedSize(QSize(GRIP_SIZE, GRIP_SIZE)); // mask QPolygon p; p << QPoint(0, GRIP_SIZE) << QPoint(GRIP_SIZE, 0) << QPoint(GRIP_SIZE, GRIP_SIZE) << QPoint(0, GRIP_SIZE); setMask(QRegion(p)); // embed embed(); updatePosition(); // event filter client->widget()->installEventFilter(this); // show show(); }
void write(std::string& filename, std::shared_ptr<AssetLibrary> assetLibrary, std::shared_ptr<Options> options) { std::ofstream file(filename, std::ios::out | std::ios::binary | std::ios::trunc); if (file) { Dependency::Ptr dependencies = Dependency::create(); std::string serializedData = embed(assetLibrary, options, dependencies); SerializedDependency serializedDependencies = dependencies->serialize(assetLibrary, options); msgpack::type::tuple<SerializedDependency, std::string> res(serializedDependencies, serializedData); std::stringstream sbuf; msgpack::pack(sbuf, res); file.write(sbuf.str().c_str(), sbuf.str().size()); file.close(); } else std::cerr << "File " << filename << " can't be opened" << std::endl; complete()->execute(this->shared_from_this()); }
bool DockContainer::x11Event( XEvent *e ) { switch( e->type ) { case DestroyNotify: if( e->xdestroywindow.window == _embeddedWinId || _embeddedWinId == 0) { _embeddedWinId = 0; emit embeddedWindowDestroyed(this); } break; case UnmapNotify: if ( e->xunmap.window == _embeddedWinId ) { kdDebug() << "Unmap Notify !!! I hate smart dockapps as wmpinboard " << command() << endl; _embeddedWinId = 0; } break; case ReparentNotify: if( _embeddedWinId && (e->xreparent.window == _embeddedWinId) && (e->xreparent.parent != winId()) ) { _embeddedWinId = 0; } else if( e->xreparent.parent == winId() ) { _embeddedWinId = e->xreparent.window; embed( _embeddedWinId ); } break; } return false; }
/** * Format string alike to "printf". * Parameters to embed to format string are get from virtual memory space. * Anyother functions are the same to printf. * @param thread * @param format_ * @param ap * @return Formatted string. */ std::string Format::parse(Thread& thread, const uint8_t* format_, const std::vector<uint8_t>& ap) { const std::string format(reinterpret_cast<const char*>(format_)); std::vector<ApContent> ap_contents; unsigned int ap_index = 0; while (ap_index < ap.size()) { std::unique_ptr<TypeStore> type(TypeStore::read(*thread.memory, *reinterpret_cast<const vaddr_t*>(ap.data() + ap_index))); ApContent content; if (type->addr == BasicTypeAddress::POINTER) { content.addr = *reinterpret_cast<const vaddr_t*>(ap.data() + ap_index + sizeof(vaddr_t)); } else if (type->addr == BasicTypeAddress::F32) { content.float_value = *reinterpret_cast<const float*>(ap.data() + ap_index + sizeof(vaddr_t)); } else if (type->addr == BasicTypeAddress::F64) { content.float_value = *reinterpret_cast<const double*>(ap.data() + ap_index + sizeof(vaddr_t)); } else { unsigned int size = type->size; if (size > sizeof(longest_uint_t)) size = sizeof(longest_uint_t); content.int_value = 0; std::memcpy(&content.int_value, ap.data() + ap_index + sizeof(vaddr_t), size); } ap_contents.push_back(content); ap_index += sizeof(vaddr_t) + type->size; } assert(ap.size() == ap_index); return embed(thread, format, ap_contents); }
void KPartSaver::next( bool random ) { // try to find working media while( m_media.count()>0 ) { if( random ) m_current = rand() % m_media.count(); else m_current++; if( m_current>=(int)m_media.count() ) m_current = 0; kdDebug() << "Trying medium " << m_media[m_current].url.url() << endl; // either start immediately or start mimejob first if( !openURL( m_media[m_current].url ) ) { m_media.remove( m_media.at(m_current) ); m_current--; } else return; } // create background widget m_back = new TQLabel( i18n("All of your files are unsupported"), this ); m_back->tqsetAlignment( AlignCenter ); embed( m_back ); m_back->show(); // nothing found, set to invalid m_current = -1; }
int main(int argc, char * argv[]) { struct arguments args; parse_arguments(argc, argv, &args); struct jpeg_compress_struct outputinfo; JBLOCKARRAY coef_buffers[MAX_COMPONENTS]; FILE *output = setup_output(args.outputname, &outputinfo); read_DCT(args.inputname, coef_buffers, &outputinfo); unsigned int seed = (unsigned) strtoul(args.userPassword, NULL, 10); node *root; size_t usable_size = make_linked_list(coef_buffers, seed, &root); if (args.embedFlag) { embed(coef_buffers, args.embedMessage, root, usable_size); write_DCT(args.outputname, coef_buffers, &outputinfo); } else if (args.extractFlag) { extract(args.message_size, root, usable_size); } fclose(output); return 0; }
//================================================ void qa_dTof() { gStyle->SetOptStat(0); if(year==2013) run_type = "Run13_pp500"; else if(year==2014) run_type = "Run14_AuAu200"; embed(); }
KPartSaver::KPartSaver( WId id ) : KScreenSaver( id ), m_timer(), m_part(0), m_current(-1), m_back(0) { // install signal handlers to make sure that nspluginviewer is shutdown correctly // move this into the nspluginviewer kpart code if( !g_inited ) { g_inited = true; g_savers.setAutoDelete( true ); srand( time(0) ); // install signal handler signal( SIGINT, exitHandler ); // Ctrl-C will cause a clean exit... signal( SIGTERM, exitHandler ); // "kill"... signal( SIGHUP, exitHandler ); // "kill -HUP" (hangup)... signal( SIGKILL, exitHandler ); // "kill -KILL" //atexit( ( void (*)(void) ) exitHandler ); } g_savers.append( this ); closeURL(); // load config KConfig *cfg = kapp->config(); cfg->setGroup( "Misc" ); m_single = cfg->readBoolEntry( "Single", true ); m_delay = cfg->readNumEntry( "Delay", 60 ); m_random = cfg->readBoolEntry( "Random", false ); m_files = cfg->readListEntry( "Files" ); if( m_files.count()==0 ) { // create background widget m_back = new TQLabel( i18n("The screen saver is not configured yet."), this ); m_back->tqsetAlignment( AlignCenter ); embed( m_back ); m_back->show(); } else { // queue files for( unsigned int n=0; n<m_files.count(); n++ ) queue( KURL::fromPathOrURL( m_files[n] ) ); // play files if( m_single ) next( m_random ); else { next( m_random ); m_timer = new TQTimer( this ); m_timer->start( m_delay*1000, true ); connect( m_timer, TQT_SIGNAL(timeout()), TQT_SLOT(timeout()) ); } } }
KEuphoriaScreenSaver::KEuphoriaScreenSaver( WId id ) : KScreenSaver( id ) { _effect = new EuphoriaWidget; readSettings(); embed( _effect ); _effect->show(); }
KFireSaverKSS( WId id ) : KScreenSaver( id ) { setBackgroundColor( black ); erase(); saver = new KFireSaver; embed(saver); saver->show(); }
GameScreenSaver::GameScreenSaver(WId id) : KScreenSaver(id) { QPalette p = QPalette(); p.setColor(QWidget::backgroundRole(), Qt::black); setPalette(p); game = new GameArea(); embed(game); game->show(); }
bool KPartSaver::openURL( KURL url ) { closeURL(); // find mime type TQString mime = KMimeType::findByURL( url )->name(); // find fitting kparts KTrader::OfferList offers; offers = KTrader::self()->query( mime, "'KParts/ReadOnlyPart' in ServiceTypes" ); if( offers.count()==0 ) { kdDebug() << "Can't find proper kpart for " << mime << endl; return false; } // load kpart library TQString lib = offers.first()->library(); KLibFactory *factory = KLibLoader::self()->factory( lib.latin1() ); if( !factory ) { kdDebug() << "Library " << lib << " not found." << endl; return false; } // create kpart m_part = (KParts::ReadOnlyPart *)factory->create( TQT_TQOBJECT(this), "kpart", "KParts::ReadOnlyPart" ); if( !m_part ) { kdDebug() << "Part for " << url.url() << " can't be constructed" << endl; return false; } else embed( m_part->widget() ); // show kpart delete m_back; m_back = 0; show(); m_part->widget()->show(); // load url if( !m_part->openURL( url ) ) { kdDebug() << "Can't load " << url.url() << endl; closeURL(); return false; } return true; }
void SDLBlock::embed(SDLBlock& block) { std::vector<MessageQueue::qWriter*>::iterator iter; unsigned id; block.cover = this; for (iter = block.context.begin(), id = 0; iter != block.context.end(); ++iter, ++id) { if (*iter) embed(**iter, id); } }
static void start(struct afb_req request) { struct json_object *obj; const char *id, *mode; char *query; int rc; /* get the id */ id = afb_req_value(request, _id_); if (id == NULL) { afb_req_fail(request, "bad-request", "missing 'id'"); return; } /* get the mode */ mode = afb_req_value(request, _mode_); if (mode == NULL || !strcmp(mode, _auto_)) { mode = afb_interface->mode == AFB_MODE_REMOTE ? _remote_ : _local_; } /* create the query */ rc = asprintf(&query, "{\"id\":\"%s\",\"mode\":\"%s\"}", id, mode); if (rc < 0) { afb_req_fail(request, "server-error", "out of memory"); return; } /* calls the service */ obj = jbus_call_sj_sync(jbus, _start_, query); if (afb_interface->verbosity) fprintf(stderr, "(afm-main-plugin) start(%s) -> %s\n", query, obj ? json_object_to_json_string(obj) : "NULL"); free(query); /* check status */ obj = json_object_get(obj); if (obj == NULL) { afb_req_fail(request, "failed", "framework daemon failure"); return; } /* embed if needed */ if (json_object_get_type(obj) == json_type_int) obj = embed(_runid_, obj); afb_req_success(request, obj, NULL); }
static void embed_call_void_callback(int status, struct json_object *obj, struct memo *memo) { if (afb_interface->verbosity) fprintf(stderr, "(afm-main-plugin) %s(true) -> %s\n", memo->method, obj ? json_object_to_json_string(obj) : "NULL"); if (obj == NULL) { afb_req_fail(memo->request, "failed", "framework daemon failure"); } else { obj = json_object_get(obj); obj = embed(memo->method, obj); if (obj == NULL) { afb_req_fail(memo->request, "failed", "framework daemon failure"); } else { afb_req_success(memo->request, obj, NULL); } } afb_req_unref(memo->request); free(memo); }
pseudonym *polypseud_encrypt(const polypseud_ctx *ctx, EC_POINT *yK, const char *uid) { BIGNUM *k = BN_new(); if(BN_rand_range(k, ctx->p) == 0) return NULL; EC_POINT *point = embed(ctx, (unsigned char*)uid, strlen(uid)); pseudonym *pseud = (pseudonym*)malloc(sizeof(pseudonym)); pseud->a = EC_POINT_new(ctx->ec_group); pseud->b = EC_POINT_new(ctx->ec_group); pseud->c = EC_POINT_dup(yK, ctx->ec_group); EC_POINT_mul(ctx->ec_group, pseud->a, NULL, ctx->g, k, ctx->bn_ctx); EC_POINT_mul(ctx->ec_group, pseud->b, NULL, yK, k, ctx->bn_ctx); EC_POINT_add(ctx->ec_group, pseud->b, pseud->b, point, ctx->bn_ctx); EC_POINT_free(point); BN_free(k); return pseud; }
void MinimapGui::presentMap(const CreatureView* creature, Rectangle bounds, Renderer& r, function<void(double, double)> clickFun) { const Level* level = creature->getLevel(); double scale = min(double(bounds.getW()) / level->getBounds().getW(), double(bounds.getH()) / level->getBounds().getH()); while (1) { update(level, level->getBounds(), creature, true); renderMap(r, Rectangle(Vec2(0, 0), embed(level->getBounds().getBottomRight(), bounds.getBottomRight()))); r.drawAndClearBuffer(); Event event; while (r.pollEvent(event)) { if (event.type == Event::KeyPressed) return; if (event.type == Event::MouseButtonPressed) { clickFun(double(event.mouseButton.x) / scale, double(event.mouseButton.y) / scale); return; } } } }
int main(int argc, char *argv[]){ char infile_path[PATH_SIZE]; char outfile_path[PATH_SIZE]; char config_path[PATH_SIZE]; char orig_out_path[PATH_SIZE]; FILE *config; // set default parameters for testing strcpy(infile_path, "audio/input.wav"); strcpy(outfile_path, "audio/out.wav"); strcpy(orig_out_path, "audio/orig_out.wav"); strcpy(config_path, "wmark.cfg"); // // Parse parameters // if(argc > 1) strncpy(infile_path, argv[1], PATH_SIZE); if(argc > 2) strncpy(outfile_path, argv[2], PATH_SIZE); if(argc > 3) strncpy(config_path, argv[3], PATH_SIZE); gen_default_wmark(); if(ERROR == parse_config(config_path)){ fprintf(stderr, "Error parsing config"); goto main_freedom; } if(embed_verbose){ print_embedding_info(infile_path, outfile_path, orig_out_path, config_path); print_watermark_info(); } if(embed(infile_path, outfile_path, orig_out_path)) goto main_freedom; main_freedom: free(wmark->message); free(wmark); } // main
void NSPluginInstance::doLoadPlugin() { if (!inited) { delete _button; _button = 0L; _loader = NSPluginLoader::instance(); setBackgroundMode(QWidget::NoBackground); WId winid = stub->winId(); if( winid != 0 ) { setProtocol(QXEmbed::XPLAIN); embed( winid ); } else { setProtocol(QXEmbed::XEMBED); } // resize before showing, some plugins are stupid and can't handle repeated // NPSetWindow() calls very well (viewer will avoid the call if not shown yet) resizePlugin(width(), height()); displayPlugin(); show(); inited = true; } }
static void install(struct afb_req request) { struct json_object *obj, *added; char *query; const char *filename; struct afb_arg arg; /* get the argument */ arg = afb_req_get(request, "widget"); filename = arg.path; if (filename == NULL) { afb_req_fail(request, "bad-request", "missing 'widget' file"); return; } /* makes the query */ if (0 >= asprintf(&query, "\"%s\"", filename)) { afb_req_fail(request, "server-error", "out of memory"); return; } obj = jbus_call_sj_sync(jbus, _install_, query); if (afb_interface->verbosity) fprintf(stderr, "(afm-main-plugin) install(%s) -> %s\n", query, obj ? json_object_to_json_string(obj) : "NULL"); free(query); /* check status */ if (obj == NULL) { afb_req_fail(request, "failed", "framework daemon failure"); return; } /* embed if needed */ if (json_object_object_get_ex(obj, _added_, &added)) obj = added; obj = json_object_get(obj); obj = embed(_id_, obj); afb_req_success(request, obj, NULL); }
//_____________________________________________ SizeGrip::SizeGrip( Decoration* decoration ):QWidget(nullptr) ,m_decoration( decoration ) { setAttribute(Qt::WA_NoSystemBackground ); setAutoFillBackground( false ); // cursor setCursor( Qt::SizeFDiagCursor ); // size setFixedSize( QSize( GripSize, GripSize ) ); // mask QPolygon p; p << QPoint( 0, GripSize ) << QPoint( GripSize, 0 ) << QPoint( GripSize, GripSize ) << QPoint( 0, GripSize ); setMask( QRegion( p ) ); // embed embed(); updatePosition(); // connections auto c = decoration->client().data(); connect( c, &KDecoration2::DecoratedClient::widthChanged, this, &SizeGrip::updatePosition ); connect( c, &KDecoration2::DecoratedClient::heightChanged, this, &SizeGrip::updatePosition ); connect( c, &KDecoration2::DecoratedClient::activeChanged, this, &SizeGrip::updateActiveState ); // show show(); }
void iwt2(unsigned int N, unsigned int flags, const long shifts[N], const long odims[N], const long ostr[N], complex float* out, const long idims[N], const long istr[N], const complex float* in, const long minsize[N], const long flen, const float filter[2][2][flen]) { assert(wavelet_check_dims(N, flags, odims, minsize)); if (0 == flags) { // note: recursion does *not* end here assert(md_check_compat(N, 0u, odims, idims)); md_copy2(N, idims, ostr, out, istr, in, CFL_SIZE); return; } // check input dimensions long idims2[N]; wavelet_coeffs2(N, flags, idims2, odims, minsize, flen); assert(md_check_compat(N, 0u, idims2, idims)); long wdims2[2 * N]; wavelet_dims(N, flags, wdims2, odims, flen); // only consider transform dims... long dims1[N]; md_select_dims(N, flags, dims1, odims); long wdims[2 * N]; wavelet_dims(N, flags, wdims, dims1, flen); long level_coeffs = md_calc_size(2 * N, wdims); // ... which get embedded in dimension b unsigned int b = ffs(flags) - 1; long istr2[2 * N]; md_calc_strides(2 * N, istr2, wdims, istr[b]); // merge with original strides for (unsigned int i = 0; i < N; i++) if (!MD_IS_SET(flags, i)) istr2[i] = istr[i]; assert(idims[b] >= level_coeffs); long offset = (idims[b] - level_coeffs) * (istr[b] / CFL_SIZE); long bands = md_calc_size(N, wdims + N); long coeffs = md_calc_size(N, wdims + 0); // subtract coefficients in high band idims2[b] -= (bands - 1) * coeffs; assert(idims2[b] > 0); debug_printf(DP_DEBUG4, "ifwt2: flags:%d lcoeffs:%ld coeffs:%ld (space:%ld) bands:%ld str:%ld off:%ld\n", flags, level_coeffs, coeffs, idims2[b], bands, istr[b], offset / ostr[b]); // fix me we need temp storage complex float* tmp = md_alloc_sameplace(2 * N, wdims2, CFL_SIZE, out); long tstr[2 * N]; md_calc_strides(2 * N, tstr, wdims2, CFL_SIZE); md_copy2(2 * N, wdims2, tstr, tmp, istr2, in + offset, CFL_SIZE); long shifts0[N]; for (unsigned int i = 0; i < N; i++) shifts0[i] = 0; unsigned int flags2 = wavelet_filter_flags(N, flags, wdims, minsize); assert((0 == offset) == (0u == flags2)); if (0u != flags2) { long idims3[N]; wavelet_coeffs2(N, flags2, idims3, wdims2, minsize, flen); long istr3[N]; embed(N, flags, istr3, idims3, istr); iwt2(N, flags2, shifts0, wdims2, tstr, tmp, idims3, istr3, in, minsize, flen, filter); } iwtN(N, flags, shifts, odims, ostr, out, tstr, tmp, flen, filter); md_free(tmp); }
int main(int argc, char ** argv) { lua_State * L = luaL_newstate(); if (!readTOC(L, argv[0])) { if (argc < 2) { // display usage message and exit printf("This copy of enceladus has no embedded lua program to run\n"); printf("Please embed one: enceladus main.lua lib.lua ...\n"); return 1; } // parse command line and embed lua code, then exit parse_args(&argc, &argv); char * outname = embed(L, argc, argv); if (outname) { printf("Embed successful. Output file: %s\n", outname); } else { fprintf(stderr, "Embed failed. Aborting.\n"); } return 0; } // TOC read successful - we have an embedded lua program to run // initialize standard libraries luaL_openlibs(L); // load any statically linked libraries enceladus_init_static_libs(L); // grab the entry point // the name is on top of the stack and the table of packed files right // below, thanks to readTOC lua_gettable(L, -2); // toc{} main() if (lua_type(L, -1) != LUA_TFUNCTION) { fprintf(stderr, "Error loading entry point: %s\n", lua_tostring(L, -1)); return 1; } // install our custom loader for the embedded libraries lua_insert(L, -2); if (!registerLoader(L)) { fprintf(stderr, "Error registering custom loader: %s\n", lua_tostring(L, -1)); return 1; } // marshal arguments into lua lua_newtable(L); // toc{} main() arg{} for (int i = 0; i < argc; ++i) { lua_pushstring(L, argv[i]); // toc{} main() arg{} argv[i] lua_rawseti(L, -2, i); // toc{} main() arg{} } lua_setglobal(L, "arg"); // toc{} main() for (int i = 1; i < argc; ++i) { lua_pushstring(L, argv[i]); // toc{} main() argv[i]... } // call lua_getglobal(L, "debug"); // ... debug lua_getfield(L, -1, "traceback"); // ... debug debug.traceback lua_insert(L, 1); // debug.traceback ... debug lua_pop(L, 1); // debug.traceback ... if (lua_pcall(L, argc-1, 0, 1) != 0) { // error handling fprintf(stderr, "error: %s\n", lua_tostring(L, -1)); return 1; } return 0; }