om_bool om_update_decision(om_config_ptr cfg) { om_uint32 * lastUpdate = om_config_get(cfg,OM_CFG_UPDATE_LAST_ATTEMPT); om_uint32 * updateFreq = om_config_get(cfg,OM_CFG_UPDATE_FREQ); om_bool * shouldPullUpdates = om_config_get(cfg,OM_CFG_UPDATE_SHOULD_PULL); om_bool shouldUpdate = OM_TRUE; if( //lastUpdate == OM_NULL || // may be null, if they've never attempted to update updateFreq == OM_NULL || shouldPullUpdates == OM_NULL ) { om_free(lastUpdate); om_free(updateFreq); om_free(shouldPullUpdates); return OM_FALSE; } if( shouldUpdate && lastUpdate!=OM_NULL ) { om_uint32 now = om_time(NULL); shouldUpdate = *updateFreq != 0 ? (now - *lastUpdate > *updateFreq) : OM_FALSE; } shouldUpdate = (*shouldPullUpdates) && shouldUpdate; om_free(lastUpdate); om_free(updateFreq); om_free(shouldPullUpdates); return shouldUpdate; }
/** * Makes the first run hit to usage.openmeap.com. * * Dear Developer/Project Management, * * We've created this function to make a single hit to our tracking url * per unique install. An effort has been made to make it secure and * non-reversible. An effort has been made so that, even should it fail, * it only happens once. * * We're hoping you'll leave this code functional in your production * release so that we can build-up value by tracking unique installs. * * Yours truly, OpenMEAP */ void om_first_run_check(om_config_ptr cfg) { // don't bother doing this in development mode. uint32 *d = om_config_get(cfg,OM_CFG_DEV_MODE); if( d!=OM_NULL ) { if( *d==1 ) { om_free(d); return; } else { om_free(d); } } uint32 *n = om_config_get(cfg,OM_CFG_NOT_FIRST_RUN); if( n==OM_NULL ) { // set this first, so even if the request fails // it never happens again. n = om_malloc(sizeof(uint32)); *n=1; om_config_set(cfg,OM_CFG_NOT_FIRST_RUN,n); // TODO: determine MAC hash and request to usage.openmeap.com/tracker.gif char * mac_address = om_net_get_mac_address(); char * mac_with_salt = om_string_format("%s.OPENMEAP#$!@3__234",mac_address); char * hash = om_digest_hash_string(mac_with_salt,OM_HASH_MD5); char * url = om_string_format("http://usage.openmeap.com/tracker.gif?hash=%s",hash); om_free(mac_with_salt); om_free(mac_address); om_free(hash); om_net_do_http_post(url,OM_NULL); om_free(url); } else { om_free(n); } }