void GoogleTranslator::apply(QString* item, QString translatedValue, TranslationType transType) { QString value = *item; QString rxString = ""; switch(transType) { case ttMonthName: rxString = "(Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|Jun(?:e)?|Jul(?:y)?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)"; break; case ttDayName: rxString = "(Mon(?:day)?|Tue(?:sday)?|Wed(?:nesday)?|Thu(?:rsday)?|Fri(?:day)?|Sat(?:urday)?|Sun(?:day)?)"; break; default: addToCache(value, translatedValue); value = fixCaps(translatedValue.trimmed()); break; } if(rxString!="") { QRegExp rx(rxString); if(rx.indexIn(value)!=-1) { QString translation = translatedValue.trimmed(); translation = fixCaps(translation); addToCache(fullDateName(rx.cap(0)), translation); if(transType == ttDayName) translation = translation.left(3); value = value.replace(rx, translation); } } *item = value; }
bool operator()(const AbstractGroupableItem *i1, const AbstractGroupableItem *i2) { if (m_groupManager && m_groupManager->separateLaunchers()) { if (i1->isStartupItem()) { if (i2->isStartupItem()) { return i1->name().toLower() < i2->name().toLower(); } return false; } if (i2->isStartupItem()) { return true; } if (i1->itemType() == LauncherItemType) { if (i2->itemType() == LauncherItemType) { return i1->name().toLower() < i2->name().toLower(); } return true; } if (i2->itemType() == LauncherItemType) { return false; } } if (!m_priorityCache.contains(i1->id())) { addToCache(i1); } if (!m_priorityCache.contains(i2->id())) { addToCache(i2); } QList<int>::const_iterator it1 = m_priorityCache[i1->id()].constBegin(); QList<int>::const_iterator it2 = m_priorityCache[i2->id()].constBegin(); QList<int>::const_iterator i1end = m_priorityCache[i1->id()].constEnd(); QList<int>::const_iterator i2end = m_priorityCache[i2->id()].constEnd(); while (it1 != i1end) { if (it2 == i2end) { return true; } else if (*it1 == *it2) { it1++; it2++; } else { return *it1 < *it2; } } return false; }
Resources::Resources(SherlockEngine *vm) : _vm(vm), _cache(vm) { _resourceIndex = -1; if (_vm->_interactiveFl) { if (!IS_3DO) { addToCache("vgs.lib"); addToCache("talk.lib"); addToCache("journal.txt"); if (IS_SERRATED_SCALPEL) { addToCache("sequence.txt"); addToCache("portrait.lib"); } else { addToCache("walk.lib"); } } else { // 3DO // ITEM data from VGS.LIB is in ITEM.LIB addToCache("item.lib"); // talk.lib - resources themselves seem to be the same, although a few texts were slightly changed addToCache("talk.lib"); // remaining files are missing // portraits were replaced with FMV } } }
int RS_Settings::readNumEntry(const RS_String& key, int def, bool* ok) { #if QT_VERSION>=0x030000 // lookup: RS_String sret = readEntryCache(key); if (sret==RS_String::null) { int ret; QSettings s(QSettings::Ini); s.insertSearchPath(QSettings::Windows, companyKey); ret = s.readNumEntry(QString("%1%2%3").arg(appKey).arg(group).arg(key), def, ok); addToCache(key, RS_String("%1").arg(ret)); return ret; } else { return sret.toInt(); } #else return def; #endif }
RS_String RS_Settings::readEntry(const RS_String& key, const RS_String& def, bool* ok) { #if QT_VERSION>=0x030000 // lookup: RS_String ret = readEntryCache(key); if (ret==RS_String::null) { QSettings s(QSettings::Ini); s.insertSearchPath(QSettings::Windows, companyKey); ret = s.readEntry(QString("%1%2%3").arg(appKey).arg(group).arg(key), def, ok); addToCache(key, ret); } return ret; #else return def; #endif }
void Resources::getResourceNames(const Common::String &libraryFile, Common::StringArray &names) { addToCache(libraryFile); LibraryIndex &libIndex = _indexes[libraryFile]; for (LibraryIndex::iterator i = libIndex.begin(); i != libIndex.end(); ++i) { names.push_back(i->_key); } }
KviCachedPixmap * KviIconManager::getPixmapWithCache(const QString & szName) { if(szName.isEmpty()) return 0; KviCachedPixmap * pCache = m_pCachedImages->find(szName); if(pCache) { pCache->updateLastAccessTime(); return pCache; } QPixmap * pPix = 0; QString szRetPath; if(g_pApp->findImage(szRetPath,szName)) { pPix = new QPixmap(szRetPath); if(pPix->isNull()) { delete pPix; // it is not an valid image!!! (really bad situation...) pPix = 0; return 0; } } else { return 0; } pCache = new KviCachedPixmap(pPix,QString(szRetPath)); addToCache(szName,pCache); return pCache; }
void CCCSHandler::process(CCCSData& data) { CC_TYPE type = data.getType(); switch (type) { case CT_TERMINATE: if (m_state == CS_ACTIVE) { wxLogMessage(wxT("CCS: Link between %s and %s has been terminated"), data.getLocal().c_str(), data.getRemote().c_str()); m_stateChange = true; m_state = CS_CONNECTED; m_inactivityTimer.stop(); m_handler->ccsLinkEnded(data.getRemote()); } break; case CT_DTMFNOTFOUND: wxLogMessage(wxT("CCS: Cannot map %s to a callsign"), m_yourCall.Mid(1U).c_str()); m_stateChange = true; m_state = CS_CONNECTED; m_inactivityTimer.stop(); m_handler->ccsLinkFailed(m_yourCall.Mid(1U)); break; case CT_DTMFFOUND: wxLogMessage(wxT("CCS: Mapped %s to %s, added to the cache"), m_yourCall.Mid(1U).c_str(), data.getRemote().c_str()); addToCache(m_yourCall.Mid(1U), data.getRemote()); m_stateChange = true; m_yourCall = data.getRemote(); m_handler->ccsLinkMade(m_yourCall); break; default: break; } }
int initTriggerModule() { CONDITIONREGISTER cr; TRIGGERREGISTER tr; ACTIONREGISTER ar; int res; DWORD triggerID; log_debugA("Variables: initTriggerModule"); if (!ServiceExists(MS_TRIGGER_REGISTERTRIGGER)) { log_debugA("Variables: %s does not exist", MS_TRIGGER_REGISTERTRIGGER); return -1; } ZeroMemory(&tr, sizeof(tr)); tr.cbSize = sizeof(tr); tr.pszName = TRIGGERNAME; tr.hInstance = hInst; tr.pfnDlgProc = DlgProcOptsStringChange; tr.pszTemplate = MAKEINTRESOURCEA(IDD_TRG_STRINGCHANGE); tr.dFlags = DF_TEXT|DF_TCHAR; res = CallService(MS_TRIGGER_REGISTERTRIGGER, 0, (LPARAM)&tr); log_debugA("Variables: %s registered (%d)", TRIGGERNAME, res); ZeroMemory(&ar, sizeof(ACTIONREGISTER)); ar.cbSize = sizeof(ACTIONREGISTER); ar.pszName = "Variables: Parse string"; ar.hInstance = hInst; ar.pfnDlgProc = DlgProcOptsParseString; ar.pszTemplate = MAKEINTRESOURCEA(IDD_ACT_PARSESTRING); ar.actionFunction = ParseStringAction; ar.flags = ARF_FUNCTION|ARF_TCHAR; CallService(MS_TRIGGER_REGISTERACTION, 0, (LPARAM)&ar); ZeroMemory(&cr, sizeof(CONDITIONREGISTER)); cr.cbSize = sizeof(CONDITIONREGISTER); cr.pszName = "Variables: Condition"; cr.hInstance = hInst; cr.pfnDlgProc = DlgProcOptsCondition; cr.pszTemplate = MAKEINTRESOURCEA(IDD_CND_PARSESTRING); cr.conditionFunction = ParseStringCondition; cr.flags = CRF_FUNCTION|CRF_TCHAR; CallService(MS_TRIGGER_REGISTERCONDITION, 0, (LPARAM)&cr); // fill cache triggerID = 0; do { triggerID = (DWORD)CallService(MS_TRIGGER_FINDNEXTTRIGGERID, triggerID, (LPARAM)TRIGGERNAME); if (triggerID == 0) { continue; } addToCache(triggerID); } while (triggerID != 0); stringChangeTimerID = SetTimer(NULL, 0, CHECKSTRINGDELAY, checkStringsTimer); return res; }
void ProfileManager::moveToCache(const uint32_t id) { if (inPersistent(id)) { Profile * profile = getProfileByID(id); m_profiles_persistent.erase(id); addToCache(profile); } else Log::warn("ProfileManager::moveToCache", "Tried to move profile with id %d from persistent to cache while not present", id); }
Resources::Resources(SherlockEngine *vm) : _vm(vm), _cache(vm) { _resourceIndex = -1; if (_vm->_interactiveFl) { if (_vm->getPlatform() != Common::kPlatform3DO) { addToCache("vgs.lib"); addToCache("talk.lib"); addToCache("journal.txt"); if (IS_SERRATED_SCALPEL) { addToCache("sequence.txt"); addToCache("portrait.lib"); } } else { // 3DO // ITEM data from VGS.LIB is in ITEM.LIB // resources themselves start with width and height as UINT16BE // but after that they are different. Don't seem to be raw data //addToCache("item.lib"); // talk.lib - resources themselves seem to be the same, although a few texts were slightly changed addToCache("talk.lib"); // remaining files are missing // portraits were replaced with FMV } } }
void gotNameLookup(const Callback &cb, const URI &origNamedUri, ServiceIterator *services, const Fingerprint &hash, const std::string &str, bool success) { if (!success) { doNameLookup(cb, origNamedUri, services, ServiceIterator::GENERAL_ERROR); return; } services->finished(ServiceIterator::SUCCESS); RemoteFileId rfid(hash, URI(origNamedUri.context(), str)); addToCache(origNamedUri, rfid); cb(origNamedUri, &rfid); }
QgsCoordinateTransform::QgsCoordinateTransform( const QgsCoordinateReferenceSystem &source, const QgsCoordinateReferenceSystem &destination ) { d = new QgsCoordinateTransformPrivate( source, destination, QgsCoordinateTransformContext() ); if ( !d->checkValidity() ) return; if ( !setFromCache( d->mSourceCRS, d->mDestCRS, d->mSourceDatumTransform, d->mDestinationDatumTransform ) ) { d->initialize(); addToCache(); } }
void the::texture::initDefaults() { logger::info("[Texture] create defaults..."); addToCache(the::texture::make(the::image::get("def::black"),"def::black")); addToCache(the::texture::make(the::image::get("def::red") ,"def::red")); addToCache(the::texture::make(the::image::get("def::green"),"def::green")); addToCache(the::texture::make(the::image::get("def::blue") ,"def::blue")); addToCache(the::texture::make(the::image::get("def::base") ,"def::base")); addToCache(the::texture::make(the::image::get("def::white"),"def::white")); addToCache(the::texture::make(the::image::get("def::transparent"),"def::transparent")); }
KviCachedPixmap * KviIconManager::getPixmapWithCacheScaleOnLoad(const QString & szName, int iMaxWidth, int iMaxHeight) { if(szName.isEmpty()) return 0; KviCachedPixmap * pCache = m_pCachedImages->find(szName); if(pCache) { pCache->updateLastAccessTime(); return pCache; } QPixmap * pPix = 0; QString szRetPath; if(g_pApp->findImage(szRetPath,szName)) { pPix = new QPixmap(szRetPath); if(pPix->isNull()) { delete pPix; // it is not an valid image!!! (really bad situation...) pPix = 0; return 0; } if((pPix->width() > iMaxWidth) || (pPix->height() > iMaxHeight)) { // scale to fit int scaleW = iMaxWidth; int scaleH; scaleH = (pPix->height() * iMaxWidth) / pPix->width(); if(scaleH > iMaxHeight) { scaleH = iMaxHeight; scaleW = (scaleH * pPix->width()) / pPix->height(); } QImage img = pPix->toImage(); *pPix = QPixmap::fromImage(img.scaled(scaleW,scaleH,Qt::IgnoreAspectRatio,Qt::SmoothTransformation)); } } else { return 0; } pCache = new KviCachedPixmap(pPix,QString(szRetPath)); addToCache(szName,pCache); return pCache; }
void QgsCoordinateTransform::setDestinationCrs( const QgsCoordinateReferenceSystem &crs ) { d.detach(); d->mDestCRS = crs; if ( !d->checkValidity() ) return; d->calculateTransforms( mContext ); if ( !setFromCache( d->mSourceCRS, d->mDestCRS, d->mSourceDatumTransform, d->mDestinationDatumTransform ) ) { d->initialize(); addToCache(); } }
QPixmap * KviIconManager::getBigIcon(const QString & szName) { QPixmap * pPix = getPixmap(szName); if(pPix) return pPix; bool bOk; int iIdx = szName.toInt(&bOk); if(bOk && (iIdx >= 0)) { // was a number : this is not a filename // it was a small icon: scale it and cache it QString szTmpName = szName; szTmpName += ".scaled16to32"; pPix = getPixmap(szTmpName); if(pPix) return pPix; pPix = getSmallIcon(iIdx % KviIconManager::IconCount); if(pPix) { QImage tmp = pPix->toImage(); QImage tmp2 = tmp.scaled(32,32,Qt::IgnoreAspectRatio,Qt::SmoothTransformation); QPixmap * pPix2 = new QPixmap(); *pPix2 = QPixmap::fromImage(tmp2); KviCachedPixmap * pCache = new KviCachedPixmap(pPix2,QString()); addToCache(szTmpName,pCache); return pCache->pixmap(); } } pPix = getPixmap("kvi_bigicon_unknown.png"); if(pPix) return pPix; KviCachedPixmap * pCache = new KviCachedPixmap(new QPixmap(32,32),QString()); addToCache(szName,pCache); return pCache->pixmap(); }
QgsCoordinateTransform::QgsCoordinateTransform( const QgsCoordinateReferenceSystem &source, const QgsCoordinateReferenceSystem &destination, int sourceDatumTransform, int destinationDatumTransform ) { d = new QgsCoordinateTransformPrivate( source, destination, sourceDatumTransform, destinationDatumTransform ); #ifdef QGISDEBUG mHasContext = true; // not strictly true, but we don't need to worry if datums have been explicitly set #endif if ( !d->checkValidity() ) return; if ( !setFromCache( d->mSourceCRS, d->mDestCRS, d->mSourceDatumTransform, d->mDestinationDatumTransform ) ) { d->initialize(); addToCache(); } }
bool RS_Settings::writeEntry(const RS_String& key, const RS_String& value) { #if QT_VERSION>=0x030000 bool ret; QSettings s(QSettings::Ini); s.insertSearchPath(QSettings::Windows, companyKey); ret = s.writeEntry(QString("%1%2%3").arg(appKey).arg(group).arg(key), value); addToCache(key, value); return ret; #else return true; #endif }
void WidgetSkin::draw(int x, int y, int width, int height, eType type) { MAHandle cached = 0; // Calculate numTiles needed to be drawn, if they are many, we need to cache, otherwise draw directly... int numTiles = calculateNumTiles(width, height); if(!useCache || numTiles<100) { drawDirect(x, y, width, height, type); return; } CacheKey newKey = CacheKey(this, width, height, type); cached = getFromCache(newKey); // If we didn't find a cached widgetskin, let's generate one and save it in the cache. if(!cached) { // set malloc handler to null so that we can catch if we're out of heap and write directly to the screen then. #ifndef MOSYNC_NATIVE malloc_handler mh = set_malloc_handler(NULL); #endif int *data = new int[width*height]; if(!data) { drawDirect(x, y, width, height, type); return; } #ifndef MOSYNC_NATIVE set_malloc_handler(mh); #endif drawToData(data, 0, 0, width, height, type); CacheElement cacheElem; flushCacheUntilNewImageFits(width*height); cacheElem.image = maCreatePlaceholder(); if(maCreateImageRaw(cacheElem.image,data,EXTENT(width,height),1)!=RES_OK) { maPanic(1, "Could not create raw image"); } delete data; cacheElem.lastUsed = maGetMilliSecondCount(); cached = cacheElem.image; addToCache(newKey, cacheElem); } // Draw the cached widgetskin. Gfx_drawImage(cached, x, y); }
void QgsCoordinateTransform::setContext( const QgsCoordinateTransformContext &context ) { d.detach(); mContext = context; #ifdef QGISDEBUG mHasContext = true; #endif if ( !d->checkValidity() ) return; d->calculateTransforms( mContext ); if ( !setFromCache( d->mSourceCRS, d->mDestCRS, d->mSourceDatumTransform, d->mDestinationDatumTransform ) ) { d->initialize(); addToCache(); } }
QgsCoordinateTransform::QgsCoordinateTransform( const QgsCoordinateReferenceSystem &source, const QgsCoordinateReferenceSystem &destination, const QgsCoordinateTransformContext &context ) { mContext = context; d = new QgsCoordinateTransformPrivate( source, destination, mContext ); #ifdef QGISDEBUG mHasContext = true; #endif if ( !d->checkValidity() ) return; if ( !setFromCache( d->mSourceCRS, d->mDestCRS, d->mSourceDatumTransform, d->mDestinationDatumTransform ) ) { d->initialize(); addToCache(); } }
void DrawingExample::handleUXEvent(shared_ptr<UXEvent> event){ if (event->type == UXEventTypeTap){ canvas->removeAllChildren(); cache->removeAllChildren(); } else if (event->phase() == UXEventPhaseBegin){ addControlPointWithUXEvent(event); } else if (event->phase() == UXEventPhaseDrag){ addControlPointWithUXEvent(event); smoothLastPointForLayer(event->referenceNode->child()); } else if (event->phase() == UXEventPhaseEnd){ addControlPointWithUXEvent(event); smoothPointsForLayer((event->referenceNode)->child()); addToCache(event->referenceNode); } }
int main (int argc, char *argv[]) { time_t t; char *buf; size_t i, n; Cache_t C; C.cache = calloc (MAX_CACHE_ENTRIES, sizeof (cacheEntry_t)); C.numCacheEntries = 0; srand ((unsigned) time (&t)); for (i = 0; i < 5; i++) { buf = (char *) malloc (n = rnd (MAX_CACHE_BUF)); addToCache (&C, buf, n); } showCache (&C); deleteCache (&C); return 0; }
int playOgg(char* name) { int ret; Sound* s = findInCache(name); if (!s) { s = loadSound(name); if (s) { addToCache(s); cacheSize++; if (cacheSize > MAX_CACHE_SIZE) { deleteOldest(); cacheSize--; } } else return -1; } s->lastPlayedTime = currentTimeMillis(); return playSound(s); }
uint8 *Resources::getFileData(const Common::String &fileName, uint32 *fileSize) { debugC(4, kDebugResource, "getFileData(%s, fileSize)", fileName.c_str()); // first try to find files outside of .pak // some patched files have not been included in package. if (Common::File::exists(fileName)) { Common::File file; bool opened = file.open(fileName); if (!opened) return 0; *fileSize = file.size(); uint8 *memory = (uint8 *)new uint8[*fileSize]; file.read(memory, *fileSize); file.close(); _allocatedFileData.push_back(memory); return memory; } else { uint32 locFileSize = 0; uint8 *locFileData = 0; if (getFromCache(fileName, &locFileSize, &locFileData)) { *fileSize = locFileSize; return locFileData; } for (uint32 i = 0; i < _pakFiles.size(); i++) { locFileData = _pakFiles[i]->getFileData(fileName, &locFileSize); if (locFileData) { *fileSize = locFileSize; addToCache(_pakFiles[i]->getPackName(), fileName, locFileSize, locFileData); return locFileData; } } return 0; } }
void TileCache::run() { // qDebug() << Q_FUNC_INFO; m_lock.lock(); while (m_running) { if (m_requests.isEmpty()) { // Expire cache: expireCacheLocked(); // qDebug() << Q_FUNC_INFO << "Waiting for requests"; m_cond.wait(&m_lock); continue; } qint64 cookie = m_requests.firstKey(); if (m_requests.first().isEmpty()) { m_requests.remove(cookie); QMetaObject::invokeMethod(this, "requestDone", Q_ARG(qint64, cookie)); continue; } bool tileDone = false; Tile tile = findBestTileLocked(m_requests.first(), tileDone); m_lock.unlock(); if (!tileDone) { // generate it: tile.image = tile.page->tile(m_dpiX, m_dpiY, tile.rect); addToCache(tile); } m_lock.lock(); QMetaObject::invokeMethod(this, "tileAvailable", Q_ARG(Tile, tile), Q_ARG(qint64, cookie)); } m_lock.unlock(); // qDebug() << Q_FUNC_INFO << "Done"; }
/** * Try to load file from cache or download a remote file if not in cache * * @param m the maps containing the settings of the main.cfg file * @param content the map to update * @param hInternet the HINTERNET pointer * @param url the url to fetch * @return 0 */ int loadRemoteFile(maps** m,map** content,HINTERNET* hInternet,char *url){ char* fcontent = NULL; char* cached=isInCache(*m,url); char *mimeType=NULL; int fsize=0; map* t=getMap(*content,"xlink:href"); if(t==NULL){ t=getMap((*content),"href"); addToMap(*content,"xlink:href",url); } if(cached!=NULL){ struct stat f_status; int s=stat(cached, &f_status); if(s==0){ fcontent=(char*)malloc(sizeof(char)*(f_status.st_size+1)); FILE* f=fopen(cached,"rb"); fread(fcontent,f_status.st_size,1,f); fsize=f_status.st_size; fcontent[fsize]=0; fclose(f); addToMap(*content,"cache_file",cached); } cached[strlen(cached)-1]='m'; s=stat(cached, &f_status); if(s==0){ mimeType=(char*)malloc(sizeof(char)*(f_status.st_size+1)); FILE* f=fopen(cached,"rb"); fread(mimeType,f_status.st_size,1,f); mimeType[f_status.st_size]=0; fclose(f); } }else{ addRequestToQueue(m,hInternet,url,true); return 0; } if(fsize==0){ return errorException(*m, _("Unable to download the file."), "InternalError",NULL); } if(mimeType!=NULL){ addToMap(*content,"fmimeType",mimeType); } map* tmpMap=getMapOrFill(content,"value",""); free(tmpMap->value); tmpMap->value=(char*)malloc((fsize+1)*sizeof(char)); if(tmpMap->value==NULL || fcontent == NULL) return errorException(*m, _("Unable to allocate memory"), "InternalError",NULL); memcpy(tmpMap->value,fcontent,(fsize+1)*sizeof(char)); char ltmp1[256]; sprintf(ltmp1,"%d",fsize); addToMap(*content,"size",ltmp1); if(cached==NULL){ addToCache(*m,url,fcontent,mimeType,fsize, NULL, 0); } else{ addToMap(*content,"isCached","true"); map* tmp=getMapFromMaps(*m,"main","cacheDir"); if(tmp!=NULL){ map *c=getMap((*content),"xlink:href"); char* md5str=getMd5(c->value); char* fname=(char*)malloc(sizeof(char)*(strlen(tmp->value)+strlen(md5str)+6)); sprintf(fname,"%s/%s.zca",tmp->value,md5str); addToMap(*content,"cache_file",fname); free(fname); } } free(fcontent); free(mimeType); free(cached); return 0; }
bool overwrite_cache( const char *hostname, struct addrinfo **new_addr_out) { struct addrinfo *old_addr = getFromCache(hostname); struct addrinfo *new_addr = NULL; struct addrinfo hints; memset(&hints, 0, sizeof(hints)); hints.ai_flags = AI_CANONNAME; if (new_addr_out == NULL) return(false); if (getaddrinfo(hostname, NULL, &hints, &new_addr) != 0) { *new_addr_out = NULL; return(false); } if (old_addr == NULL) { // not currently in the cache *new_addr_out = addToCache(new_addr, hostname); } else if (((struct sockaddr_in *)new_addr->ai_addr)->sin_addr.s_addr == ((struct sockaddr_in *)old_addr->ai_addr)->sin_addr.s_addr) { freeaddrinfo(new_addr); *new_addr_out = old_addr; } else { // overwrite the current information for this host with the new information int index = nameToAddr.find(hostname); const char *duped_hostname = hosts[index].c_str(); struct sockaddr_in *pINetAddr = (struct sockaddr_in *)new_addr->ai_addr; char new_key[65]; struct addrinfo *to_free; sprintf(new_key, "%d", pINetAddr->sin_addr.s_addr); addrToName.insert(index, new_key, true); nameToAddr.insert(index, duped_hostname, true); to_free = addrs[index]; addrs[index] = new_addr; // free the old addrinfo entry for this node freeaddrinfo(to_free); *new_addr_out = new_addr; } if(*new_addr_out == NULL) { return false; } return(true); }
INT_PTR CALLBACK DlgProcOptsStringChange(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_INITDIALOG: { DBVARIANT dbv; DWORD triggerID; TranslateDialogDefault(hwndDlg); triggerID = (DWORD)lParam; if (!DBGetTriggerSetting(triggerID, NULL, MODULENAME, SETTING_TRIGGERTEXT, &dbv)) { SetDlgItemTextA(hwndDlg, IDC_FORMATTEXT, dbv.pszVal); DBFreeVariant(&dbv); } variables_skin_helpbutton(hwndDlg, IDC_SHOWHELP); break; } case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_SHOWHELP: { variables_showhelp(hwndDlg, IDC_FORMATTEXT, VHF_FULLDLG|VHF_SETLASTSUBJECT, NULL, NULL); break; } } break; case TM_ADDTRIGGER: { // wParam = trigger ID // lParam = (TRIGGERREGISTER *) DWORD triggerID; TCHAR *tszFormatText; triggerID = (DWORD)wParam; tszFormatText = Hlp_GetDlgItemText(hwndDlg, IDC_FORMATTEXT); if (tszFormatText != NULL) { DBWriteTriggerSettingTString(triggerID, NULL, MODULENAME, SETTING_TRIGGERTEXT, tszFormatText); free(tszFormatText); } addToCache(triggerID); break; } case TM_DELTRIGGER: { // wParam = triggerID // lParam = (TRIGGEREGISTER *) may be 0 DWORD triggerID; REMOVETRIGGERSETTINGS rts; triggerID = (DWORD)wParam; removeFromCache(triggerID); rts.cbSize = sizeof(REMOVETRIGGERSETTINGS); rts.prefix = PREFIX_TRIGGERID; rts.id = triggerID; rts.hContact = NULL; rts.szModule = MODULENAME; CallService(MS_TRIGGER_REMOVESETTINGS, 0, (LPARAM)&rts); break; } } return FALSE; }