diff options
author | sr55 <[email protected]> | 2016-03-12 20:18:01 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2016-03-12 20:18:01 +0000 |
commit | b29eeae239a9a3ae781f5ccb751699e7d4bd4d2a (patch) | |
tree | d31f946b700e7606b44dd1497da5c7d0e48e8a57 | |
parent | 079f2cd0381900e268201b74042300dff1e6bc81 (diff) |
Remove the CLI / LibHB Update Checker. It's been broken since we switched to HTTPS and it's terrible code.
-rw-r--r-- | gtk/src/hb-backend.c | 6 | ||||
-rw-r--r-- | libhb/hb.c | 70 | ||||
-rw-r--r-- | libhb/hb.h | 3 | ||||
-rw-r--r-- | libhb/internal.h | 3 | ||||
-rw-r--r-- | libhb/update.c | 221 | ||||
-rw-r--r-- | macosx/HBCore.m | 2 | ||||
-rw-r--r-- | test/test.c | 31 |
7 files changed, 8 insertions, 328 deletions
diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c index e5035d3e5..88a13debc 100644 --- a/gtk/src/hb-backend.c +++ b/gtk/src/hb-backend.c @@ -3025,9 +3025,9 @@ void ghb_backend_init(gint debug) { /* Init libhb */ - h_scan = hb_init( debug, 0 ); - h_queue = hb_init( debug, 0 ); - h_live = hb_init( debug, 0 ); + h_scan = hb_init( debug ); + h_queue = hb_init( debug ); + h_live = hb_init( debug ); } void diff --git a/libhb/hb.c b/libhb/hb.c index 393ced341..18cf816ff 100644 --- a/libhb/hb.c +++ b/libhb/hb.c @@ -31,11 +31,6 @@ struct hb_handle_s { int id; - /* The "Check for update" thread */ - int build; - char version[32]; - hb_thread_t * update_thread; - /* This thread's only purpose is to check other threads' states */ volatile int die; @@ -411,46 +406,13 @@ void hb_log_level_set(hb_handle_t *h, int level) global_verbosity_level = level; } -void hb_update_poll(hb_handle_t *h) -{ - uint64_t date; - - hb_log( "hb_update_poll: checking for updates" ); - date = hb_get_date(); - h->update_thread = hb_update_init( &h->build, h->version ); - - for( ;; ) - { - if (h->update_thread == 0) - { - // Closed by thread_func - break; - } - if (hb_thread_has_exited(h->update_thread)) - { - /* Immediate success or failure */ - hb_thread_close( &h->update_thread ); - break; - } - if (hb_get_date() > date + 1000) - { - /* Still nothing after one second. Connection problem, - let the thread die */ - hb_log( "hb_update_poll: connection problem, not waiting for " - "update_thread" ); - break; - } - hb_snooze( 500 ); - } -} - /** * libhb initialization routine. * @param verbose HB_DEBUG_NONE or HB_DEBUG_ALL. * @param update_check signals libhb to check for updated version from HandBrake website. * @return Handle to hb_handle_t for use on all subsequent calls to libhb. */ -hb_handle_t * hb_init( int verbose, int update_check ) +hb_handle_t * hb_init( int verbose ) { hb_handle_t * h = calloc( sizeof( hb_handle_t ), 1 ); @@ -459,18 +421,10 @@ hb_handle_t * hb_init( int verbose, int update_check ) h->id = hb_instance_counter++; - /* Check for an update on the website if asked to */ - h->build = -1; - /* Initialize opaque for PowerManagement purposes */ h->system_sleep_opaque = hb_system_sleep_opaque_init(); - if( update_check ) - { - hb_update_poll(h); - } - - h->title_set.list_title = hb_list_init(); + h->title_set.list_title = hb_list_init(); h->jobs = hb_list_init(); h->state_lock = hb_lock_init(); @@ -564,18 +518,6 @@ int hb_get_build( hb_handle_t * h ) } /** - * Checks for needed update. - * @param h Handle to hb_handle_t. - * @param version Pointer to handle where version will be copied. - * @return update indicator. - */ -int hb_check_update( hb_handle_t * h, char ** version ) -{ - *version = ( h->build < 0 ) ? NULL : h->version; - return h->build; -} - -/** * Deletes current previews associated with titles * @param h Handle to hb_handle_t */ @@ -1918,14 +1860,6 @@ static void thread_func( void * _h ) while( !h->die ) { - /* In case the check_update thread hangs, it'll die sooner or - later. Then, we join it here */ - if( h->update_thread && - hb_thread_has_exited( h->update_thread ) ) - { - hb_thread_close( &h->update_thread ); - } - /* Check if the scan thread is done */ if( h->scan_thread && hb_thread_has_exited( h->scan_thread ) ) diff --git a/libhb/hb.h b/libhb/hb.h index f2dd6e9c4..94f99bce7 100644 --- a/libhb/hb.h +++ b/libhb/hb.h @@ -30,8 +30,7 @@ extern "C" { #define HB_DEBUG_ALL 1 void hb_register( hb_work_object_t * ); void hb_register_logger( void (*log_cb)(const char* message) ); -hb_handle_t * hb_init( int verbose, int update_check ); -void hb_update_poll(hb_handle_t *h); +hb_handle_t * hb_init( int verbose ); void hb_log_level_set(hb_handle_t *h, int level); void hb_hwd_set_enable( hb_handle_t *h, uint8_t enable ); diff --git a/libhb/internal.h b/libhb/internal.h index 7c70a2bb7..c89177fa0 100644 --- a/libhb/internal.h +++ b/libhb/internal.h @@ -276,9 +276,8 @@ static inline hb_buffer_t * hb_video_buffer_init( int width, int height ) } /*********************************************************************** - * Threads: update.c, scan.c, work.c, reader.c, muxcommon.c + * Threads: scan.c, work.c, reader.c, muxcommon.c **********************************************************************/ -hb_thread_t * hb_update_init( int * build, char * version ); hb_thread_t * hb_scan_init( hb_handle_t *, volatile int * die, const char * path, int title_index, hb_title_set_t * title_set, int preview_count, diff --git a/libhb/update.c b/libhb/update.c deleted file mode 100644 index 54300e3c1..000000000 --- a/libhb/update.c +++ /dev/null @@ -1,221 +0,0 @@ -/* update.c - - Copyright (c) 2003-2016 HandBrake Team - This file is part of the HandBrake source code - Homepage: <http://handbrake.fr/>. - It may be used under the terms of the GNU General Public License v2. - For full terms see the file COPYING file or visit http://www.gnu.org/licenses/gpl-2.0.html - */ - -#include "hb.h" - -static void UpdateFunc( void * ); - -typedef struct -{ - int * build; - char * version; - -} hb_update_t; - -hb_thread_t * hb_update_init( int * build, char * version ) -{ - hb_update_t * data = calloc( sizeof( hb_update_t ), 1 ); - data->build = build; - data->version = version; - - return hb_thread_init( "update", UpdateFunc, data, - HB_NORMAL_PRIORITY ); -} - - -static void UpdateFunc( void * _data ) -{ - - hb_update_t * data = (hb_update_t *) _data; - - char* const url = HB_PROJECT_URL_APPCAST; - char* const urlz = url + strlen( HB_PROJECT_URL_APPCAST ); /* marks null-term */ - char url_host[64]; - char url_path[128]; - char query[256]; - - hb_net_t * net; - int ret; - char buf[4096]; - char * cur, * end; - int size; - int i_vers; - char s_vers[32]; /* must be no larger than hb_handle_s.version */ - int i; - - /* Setup hb_query and hb_query_two with the correct appcast file */ - hb_log( "Using %s", url ); - - /* extract host part */ - cur = strstr( HB_PROJECT_URL_APPCAST, "//" ); - if( !cur || cur+2 > urlz ) - goto error; - cur += 2; - - end = strstr( cur, "/" ); - if( !end || end > urlz ) - goto error; - - memset( url_host, 0, sizeof(url_host) ); - strncpy( url_host, cur, (end-cur) ); - - /* extract path part */ - memset( url_path, 0, sizeof(url_path) ); - strncpy( url_path, end, (urlz-end) ); - - if( !strlen( url_path )) - goto error; - - memset( query, 0, sizeof(query) ); - snprintf( query, sizeof(query), "GET %s HTTP/1.0\r\nHost: %s\r\n\r\n", url_path, url_host ); - - /* Grab the data from the web server */ - if( !( net = hb_net_open( url_host, 80 ) ) ) - { - goto error; - } - - if( hb_net_send( net, query ) < 0 ) - { - hb_log("Error: Unable to connect to server"); - hb_net_close( &net ); - goto error; - } - - size = 0; - memset( buf, 0, 4096 ); - for( ;; ) - { - ret = hb_net_recv( net, &buf[size], sizeof( buf ) - size ); - if( ret < 1 ) - { - hb_net_close( &net ); - break; - } - size += ret; - } - - cur = buf; - end = &buf[sizeof( buf )]; - - /* Make sure we got it */ - cur += 9; - if( size < 15 || strncmp( cur, "200 OK", 6 ) ) - { - hb_log("Error: We did not get a 200 OK from the server. \n"); - goto error; - } - cur += 6; - - /* Find the end of the headers and the beginning of the content */ - for( ; &cur[3] < end; cur++ ) - { - if( cur[0] == '\r' && cur[1] == '\n' && - cur[2] == '\r' && cur[3] == '\n' ) - { - cur += 4; - break; - } - } - - if( cur >= end ) - { - hb_log("Error: Found the end of the buffer before the end of the HTTP header information! \n"); - goto error; - } - - /* - * Find the <cli> tag - * Scan though each character of the buffer until we find that the first 4 characters of "cur" are "<cli" - */ - for(i=0 ; &cur[3] < end; i++, cur++ ) - { - if( cur[0] == 'c' && cur[1] == 'l' && cur[2] == 'i' && cur[3] == '>' ) - { - cur += 1; - break; - } - - /* If the CLI tag has not been found in the first 768 characters, or the end is reached, something bad happened.*/ - if (( i > 768) || ( cur >= end )) - { - hb_log("Error: Did not find the <cli> tag in the expected maximum amount of characters into the file. \n"); - goto error; - } - } - - if( cur >= end ) - { - goto error; - } - - /* - * Ok, The above code didn't position cur, it only found <cli so we need to shift cur along 3 places. - * After which, the next 10 characters are the build number - */ - cur += 3; - - if( cur >= end ) - { - hb_log("Error: Unexpected end of buffer! Could not find the build information. \n"); - goto error; - } - - /* Stable HB_PROJECT_BUILD */ - i_vers = strtol( cur, &cur, 10 ); - - if( cur >= end ) - { - hb_log("Error: Unexpected end of buffer! \n"); - goto error; - } - - /* - * The Version number is 2 places after the build, so shift cur, 2 places. - * Get all the characters in cur until the point where " is found. - */ - cur += 2; - - if( cur >= end ) - { - hb_log("Error: Unexpected end of buffer! Could not get version number. \n"); - goto error; - } - memset( s_vers, 0, sizeof( s_vers ) ); - for( i = 0; i < sizeof( s_vers ) - 1 && cur < end && *cur != '"'; i++, cur++ ) - { - s_vers[i] = *cur; - - /* If the CLI tag has not been found in the first 768 characters, or the end is reached, something bad happened.*/ - if (( cur >= end )) - { - hb_log("Error: Version number too long, or end of buffer reached. \n"); - goto error; - } - } - - if( cur >= end ) - { - goto error; - } - - /* Print the version information */ - hb_log( "latest: %s, build %d", s_vers, i_vers ); - - /* Return the build information */ - if( i_vers > HB_PROJECT_BUILD ) - { - memcpy( data->version, s_vers, sizeof(s_vers) ); - *(data->build) = i_vers; - } - -error: - free( data ); - return; -} diff --git a/macosx/HBCore.m b/macosx/HBCore.m index 15116ac56..305774d44 100644 --- a/macosx/HBCore.m +++ b/macosx/HBCore.m @@ -103,7 +103,7 @@ static void hb_error_handler(const char *errmsg) _hb_state = malloc(sizeof(struct hb_state_s)); _logLevel = level; - _hb_handle = hb_init(level, 0); + _hb_handle = hb_init(level); if (!_hb_handle) { return nil; diff --git a/test/test.c b/test/test.c index be5f854af..92e6d834f 100644 --- a/test/test.c +++ b/test/test.c @@ -53,7 +53,6 @@ /* Options */ static int debug = HB_DEBUG_ALL; -static int update = 0; static int dvdnav = 1; static char * input = NULL; static char * output = NULL; @@ -448,26 +447,6 @@ int main( int argc, char ** argv ) fprintf( stderr, "%s - %s - %s\n", HB_PROJECT_TITLE, HB_PROJECT_BUILD_TITLE, HB_PROJECT_URL_WEBSITE ); - /* Check for update */ - if( update ) - { - hb_update_poll(h); - if( ( build = hb_check_update( h, &version ) ) > -1 ) - { - fprintf( stderr, "You are using an old version of " - "HandBrake.\nLatest is %s (build %d).\n", version, - build ); - } - else - { - fprintf( stderr, "Your version of HandBrake is up to " - "date.\n" ); - } - hb_close( &h ); - hb_global_close(); - return 0; - } - /* Geeky */ fprintf( stderr, "%d CPU%s detected\n", hb_get_cpu_count(), hb_get_cpu_count() > 1 ? "s" : "" ); @@ -1160,7 +1139,6 @@ static void ShowHelp() "\n" "### General Handbrake Options---------------------------------------------\n\n" " -h, --help Print help\n" -" -u, --update Check for updates and exit\n" " -v, --verbose <#> Be verbose (optional argument: logging level)\n" " -Z. --preset <string> Use a built-in preset. Capitalization matters,\n" " and if the preset name has spaces, surround it\n" @@ -1907,7 +1885,6 @@ static int ParseOptions( int argc, char ** argv ) { "help", no_argument, NULL, 'h' }, { "version", no_argument, NULL, VERSION }, { "describe", no_argument, NULL, DESCRIBE }, - { "update", no_argument, NULL, 'u' }, { "verbose", optional_argument, NULL, 'v' }, { "no-dvdnav", no_argument, NULL, DVDNAV }, { "no-opencl", no_argument, &use_opencl, 0 }, @@ -2087,9 +2064,6 @@ static int ParseOptions( int argc, char ** argv ) case DESCRIBE: printf("%s\n", hb_get_full_description()); exit(0); - case 'u': - update = 1; - break; case 'v': if( optarg != NULL ) { @@ -2925,11 +2899,6 @@ static int count_subtitles(char **subtracks) static int CheckOptions( int argc, char ** argv ) { - if( update ) - { - return 0; - } - if (queue_import_name != NULL) { // Everything should be defined in the queue. |