Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package libimobiledevice for 
openSUSE:Factory checked in at 2026-10-22 19:24:45
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/libimobiledevice (Old)
 and      /work/SRC/openSUSE:Factory/.libimobiledevice.new.2252680 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "libimobiledevice"

Thu Oct 22 19:24:45 2026 rev:49 rq:1386763 version:1.4.0+9git.20260610

Changes:
--------
--- /work/SRC/openSUSE:Factory/libimobiledevice/libimobiledevice.changes        
2025-10-14 18:04:54.438143213 +0200
+++ 
/work/SRC/openSUSE:Factory/.libimobiledevice.new.2252680/libimobiledevice.changes
   2026-10-22 19:24:46.773464096 +0200
@@ -1,0 +2,12 @@
+Tue Oct 20 13:40:00 UTC 2026 - Martin Pluskal <[email protected]>
+
+- Update to version 1.4.0+9git.20260610 (9 commits past the 1.4.0
+  release, no SONAME change):
+  * ostrace: fix a memory leak (upstream issue #1677)
+  * afc: improve error handling; afcclient cd fix, start in
+    /Documents with --documents, progress and echo fixes
+  * endianness.h: default to little endian if __BYTE_ORDER is
+    undefined; libsrp6a-sha512: fix environ handling for Apple
+  * docs: CSS fix
+
+-------------------------------------------------------------------

Old:
----
  libimobiledevice-1.4.0+0git.20251010.tar.gz

New:
----
  libimobiledevice-1.4.0+9git.20260610.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ libimobiledevice.spec ++++++
--- /var/tmp/diff_new_pack.2OtiKz/_old  2026-10-22 19:24:47.711503301 +0200
+++ /var/tmp/diff_new_pack.2OtiKz/_new  2026-10-22 19:24:47.713503384 +0200
@@ -22,7 +22,7 @@
 # ... and python311 on SLE 15 derivates
 %{?sle15_python_module_pythons}
 Name:           libimobiledevice
-Version:        1.4.0+0git.20251010
+Version:        1.4.0+9git.20260610
 Release:        0
 Summary:        Native protocols library for iOS devices
 License:        LGPL-2.1-or-later

++++++ libimobiledevice-1.4.0+0git.20251010.tar.gz -> 
libimobiledevice-1.4.0+9git.20260610.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/libimobiledevice-1.4.0+0git.20251010/3rd_party/libsrp6a-sha512/t_misc.c 
new/libimobiledevice-1.4.0+9git.20260610/3rd_party/libsrp6a-sha512/t_misc.c
--- old/libimobiledevice-1.4.0+0git.20251010/3rd_party/libsrp6a-sha512/t_misc.c 
2025-10-10 18:08:40.000000000 +0200
+++ new/libimobiledevice-1.4.0+9git.20260610/3rd_party/libsrp6a-sha512/t_misc.c 
2026-06-10 09:51:55.000000000 +0200
@@ -77,7 +77,12 @@
  * tricks with variable ordering and sometimes define quirky
  * environment variables like $WINDOWID or $_.
  */
+#ifdef __APPLE__
+#include <crt_externs.h>
+#define environ (*_NSGetEnviron())
+#else
 extern char ** environ;
+#endif
 
 static void
 t_envhash(unsigned char * out)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/libimobiledevice-1.4.0+0git.20251010/docs/doxygen/custom.css 
new/libimobiledevice-1.4.0+9git.20260610/docs/doxygen/custom.css
--- old/libimobiledevice-1.4.0+0git.20251010/docs/doxygen/custom.css    
2025-10-10 18:08:40.000000000 +0200
+++ new/libimobiledevice-1.4.0+9git.20260610/docs/doxygen/custom.css    
2026-06-10 09:51:55.000000000 +0200
@@ -230,6 +230,7 @@
        border: solid 1px rgb(221, 221, 221);
        border-radius: 3px;
        background-color: rgb(248, 248, 248);
+       color: rgb(0,0,0);
 }
 
 div.line {
@@ -1719,4 +1720,4 @@
        #projectnumber {
                font-size: 0.75rem;
        }
-}
\ No newline at end of file
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/libimobiledevice-1.4.0+0git.20251010/include/endianness.h 
new/libimobiledevice-1.4.0+9git.20260610/include/endianness.h
--- old/libimobiledevice-1.4.0+0git.20251010/include/endianness.h       
2025-10-10 18:08:40.000000000 +0200
+++ new/libimobiledevice-1.4.0+9git.20260610/include/endianness.h       
2026-06-10 09:51:55.000000000 +0200
@@ -19,6 +19,13 @@
 #endif
 #endif
 
+#ifndef __BYTE_ORDER
+#ifndef _WIN32
+#warning __BYTE_ORDER is not defined, assuming little endian
+#endif
+#define __BYTE_ORDER __LITTLE_ENDIAN
+#endif
+
 #ifndef be16toh
 #if __BYTE_ORDER == __BIG_ENDIAN
 #define be16toh(x) (x)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/libimobiledevice-1.4.0+0git.20251010/include/libimobiledevice/afc.h 
new/libimobiledevice-1.4.0+9git.20260610/include/libimobiledevice/afc.h
--- old/libimobiledevice-1.4.0+0git.20251010/include/libimobiledevice/afc.h     
2025-10-10 18:08:40.000000000 +0200
+++ new/libimobiledevice-1.4.0+9git.20260610/include/libimobiledevice/afc.h     
2026-06-10 09:51:55.000000000 +0200
@@ -64,6 +64,7 @@
        AFC_E_NO_MEM                = 31,
        AFC_E_NOT_ENOUGH_DATA       = 32,
        AFC_E_DIR_NOT_EMPTY         = 33,
+       AFC_E_SSL_ERROR             = 34,
        AFC_E_FORCE_SIGNED_TYPE     = -1
 } afc_error_t;
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libimobiledevice-1.4.0+0git.20251010/src/afc.c 
new/libimobiledevice-1.4.0+9git.20260610/src/afc.c
--- old/libimobiledevice-1.4.0+0git.20251010/src/afc.c  2025-10-10 
18:08:40.000000000 +0200
+++ new/libimobiledevice-1.4.0+9git.20260610/src/afc.c  2026-06-10 
09:51:55.000000000 +0200
@@ -59,6 +59,27 @@
        mutex_unlock(&client->mutex);
 }
 
+static afc_error_t service_to_afc_error(service_error_t err)
+{
+       switch (err) {
+               case SERVICE_E_SUCCESS:
+                       return AFC_E_SUCCESS;
+               case SERVICE_E_INVALID_ARG:
+                       return AFC_E_INVALID_ARG;
+               case SERVICE_E_MUX_ERROR:
+                       return AFC_E_MUX_ERROR;
+               case SERVICE_E_SSL_ERROR:
+                       return AFC_E_SSL_ERROR;
+               case SERVICE_E_NOT_ENOUGH_DATA:
+                       return AFC_E_NOT_ENOUGH_DATA;
+               case SERVICE_E_TIMEOUT:
+                       return AFC_E_OP_TIMEOUT;
+               default:
+                       break;
+       }
+       return AFC_E_UNKNOWN_ERROR;
+}
+
 /**
  * Makes a connection to the AFC service on the device using the given
  * connection.
@@ -174,11 +195,16 @@
        AFCPacket_to_LE(client->afc_packet);
        debug_buffer((char*)client->afc_packet, sizeof(AFCPacket) + 
data_length);
        sent = 0;
-       service_send(client->parent, (void*)client->afc_packet, 
sizeof(AFCPacket) + data_length, &sent);
+       afc_error_t err = service_to_afc_error(service_send(client->parent, 
(void*)client->afc_packet, sizeof(AFCPacket) + data_length, &sent));
        AFCPacket_from_LE(client->afc_packet);
+       if (err != AFC_E_SUCCESS) {
+               debug_info("Failed to send packet (sent %i/%i): %s (%d)", sent, 
sizeof(AFCPacket) + data_length, afc_strerror(err), err);
+               return err;
+       }
        *bytes_sent += sent;
        if (sent < sizeof(AFCPacket) + data_length) {
-               return AFC_E_SUCCESS;
+               debug_info("Failed to send entire packet (sent %i/%i)", sent, 
sizeof(AFCPacket) + data_length);
+               return AFC_E_NOT_ENOUGH_DATA;
        }
 
        sent = 0;
@@ -190,11 +216,16 @@
                        debug_info("packet payload follows");
                        debug_buffer(payload, payload_length);
                }
-               service_send(client->parent, payload, payload_length, &sent);
+               err = service_to_afc_error(service_send(client->parent, 
payload, payload_length, &sent));
+               if (err != AFC_E_SUCCESS) {
+                       debug_info("Failed to send payload (sent: %i/%i): %s 
(%d)", sent, payload_length, afc_strerror(err), err);
+                       return err;
+               }
        }
        *bytes_sent += sent;
        if (sent < payload_length) {
-               return AFC_E_SUCCESS;
+               debug_info("Failed to send entire payload (sent: %i/%i): %s 
(%d)", sent, payload_length, afc_strerror(err), err);
+               return AFC_E_NOT_ENOUGH_DATA;
        }
 
        return AFC_E_SUCCESS;
@@ -227,21 +258,28 @@
        }
 
        /* first, read the AFC header */
-       service_receive(client->parent, (char*)&header, sizeof(AFCPacket), 
&recv_len);
-       AFCPacket_from_LE(&header);
+       afc_error_t err = service_to_afc_error(service_receive(client->parent, 
(char*)&header, sizeof(AFCPacket), &recv_len));
+       if (err != AFC_E_SUCCESS) {
+               debug_info("Failed to receive AFC header: %s (%d)", 
afc_strerror(err), err);
+               return err;
+       }
        if (recv_len == 0) {
                debug_info("Just didn't get enough.");
-               return AFC_E_MUX_ERROR;
+               return AFC_E_NOT_ENOUGH_DATA;
        }
 
        if (recv_len < sizeof(AFCPacket)) {
                debug_info("Did not even get the AFCPacket header");
-               return AFC_E_MUX_ERROR;
+               return AFC_E_NOT_ENOUGH_DATA;
        }
 
+       /* make sure endianness is correct */
+       AFCPacket_from_LE(&header);
+
        /* check if it's a valid AFC header */
        if (strncmp(header.magic, AFC_MAGIC, AFC_MAGIC_LEN) != 0) {
                debug_info("Invalid AFC packet received (magic != " AFC_MAGIC 
")!");
+               return AFC_E_UNKNOWN_PACKET_TYPE;
        }
 
        /* check if it has the correct packet number */
@@ -273,16 +311,20 @@
        buf = (char*)malloc(entire_len);
        if (this_len > 0) {
                recv_len = 0;
-               service_receive(client->parent, buf, this_len, &recv_len);
+               err = service_to_afc_error(service_receive(client->parent, buf, 
this_len, &recv_len));
+               if (err != AFC_E_SUCCESS) {
+                       free(buf);
+                       debug_info("Failed to receive data: %s (%d)", 
afc_strerror(err), err);
+               }
                if (recv_len <= 0) {
                        free(buf);
                        debug_info("Did not get packet contents!");
-                       return AFC_E_NOT_ENOUGH_DATA;
+                       return (err == AFC_E_SUCCESS) ? AFC_E_NOT_ENOUGH_DATA : 
err;
                }
                if (recv_len < this_len) {
                        free(buf);
                        debug_info("Could not receive this_len=%d bytes", 
this_len);
-                       return AFC_E_NOT_ENOUGH_DATA;
+                       return (err == AFC_E_SUCCESS) ? AFC_E_END_OF_DATA : err;
                }
        }
 
@@ -291,7 +333,11 @@
        if (entire_len > this_len) {
                while (current_count < entire_len) {
                        recv_len = 0;
-                       service_receive(client->parent, buf+current_count, 
entire_len - current_count, &recv_len);
+                       err = 
service_to_afc_error(service_receive(client->parent, buf+current_count, 
entire_len - current_count, &recv_len));
+                       if (err != AFC_E_SUCCESS) {
+                               debug_info("Error receiving data: %s (%d)", 
afc_strerror(err), err);
+                               break;
+                       }
                        if (recv_len <= 0) {
                                debug_info("Error receiving data (recv returned 
%d)", recv_len);
                                break;
@@ -299,7 +345,9 @@
                        current_count += recv_len;
                }
                if (current_count < entire_len) {
-                       debug_info("WARNING: could not receive full packet 
(read %s, size %d)", current_count, entire_len);
+                       free(buf);
+                       debug_info("ERROR: Could not receive entire packet 
(read %i/%i)", current_count, entire_len);
+                       return (err == AFC_E_SUCCESS) ? AFC_E_END_OF_DATA : err;
                }
        }
 
@@ -1299,14 +1347,14 @@
                        return "Internal error";
                case AFC_E_MUX_ERROR:
                        return "MUX error";
+               case AFC_E_SSL_ERROR:
+                       return "SSL error";
                case AFC_E_NO_MEM:
                        return "Out of memory";
                case AFC_E_NOT_ENOUGH_DATA:
                        return "Not enough data";
                case AFC_E_DIR_NOT_EMPTY:
                        return "Directory not empty";
-               case AFC_E_FORCE_SIGNED_TYPE:
-                       return "Force signed type";
                default:
                        break;
        }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libimobiledevice-1.4.0+0git.20251010/src/ostrace.c 
new/libimobiledevice-1.4.0+9git.20260610/src/ostrace.c
--- old/libimobiledevice-1.4.0+0git.20251010/src/ostrace.c      2025-10-10 
18:08:40.000000000 +0200
+++ new/libimobiledevice-1.4.0+9git.20260610/src/ostrace.c      2026-06-10 
09:51:55.000000000 +0200
@@ -251,6 +251,7 @@
                        break;
                }
                oswt->cbfunc(buf, received, oswt->user_data);
+               free(buf);
        }
 
        if (oswt) {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/libimobiledevice-1.4.0+0git.20251010/tools/afcclient.c 
new/libimobiledevice-1.4.0+9git.20260610/tools/afcclient.c
--- old/libimobiledevice-1.4.0+0git.20251010/tools/afcclient.c  2025-10-10 
18:08:40.000000000 +0200
+++ new/libimobiledevice-1.4.0+9git.20260610/tools/afcclient.c  2026-06-10 
09:51:55.000000000 +0200
@@ -141,6 +141,7 @@
 #ifndef HAVE_READLINE
 #ifdef _WIN32
 #define BS_CC '\b'
+#define getch _getch
 #else
 #define BS_CC 0x7f
 #define getch getchar
@@ -155,12 +156,18 @@
                        break;
                }
                if (isprint(c)) {
-                       if (len < maxlen-1)
+                       if (len < maxlen-1) {
                                buf[len++] = c;
+#ifdef _WIN32
+                               fputc(c, stdout);
+#endif
+                       }
                } else if (c == BS_CC) {
                        if (len > 0) {
                                fputs("\b \b", stdout);
                                len--;
+                       } else {
+                               fputc(0x07, stdout);
                        }
                }
        }
@@ -325,7 +332,9 @@
 
        for (int i = 0; i < c_count; i++) {
                if (!strcmp(comps[i].str, "..")) {
-                       o--;
+                       if (o > 1) {
+                               o--;
+                       }
                        continue;
                } else if (!strcmp(comps[i].str, ".")) {
                        continue;
@@ -1002,6 +1011,9 @@
                        }
                }
        }
+       if (progress) {
+               printf("\n");
+       }
        free(buf);
        afc_file_close(afc, fh);
        fclose(f);
@@ -1192,8 +1204,10 @@
                }
                if (p == curdir) {
                        *(p+1) = '\0';
+                       curdir_len = 1;
                } else {
                        *p = '\0';
+                       curdir_len = strlen(curdir);
                }
                return;
        }
@@ -1217,7 +1231,6 @@
                free(path);
                return;
        }
-
        free(curdir);
        curdir = path;
        curdir_len = strlen(curdir);
@@ -1605,8 +1618,13 @@
                lockdownd_client_free(lockdown);
                lockdown = NULL;
 
-               curdir = strdup("/");
-               curdir_len = 1;
+               if (appid && !use_container) {
+                       curdir = strdup("/Documents");
+                       curdir_len = 10;
+               } else {
+                       curdir = strdup("/");
+                       curdir_len = 1;
+               }
 
                if (argc > 0) {
                        // command line mode
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/libimobiledevice-1.4.0+0git.20251010/tools/idevicebackup2.c 
new/libimobiledevice-1.4.0+9git.20260610/tools/idevicebackup2.c
--- old/libimobiledevice-1.4.0+0git.20251010/tools/idevicebackup2.c     
2025-10-10 18:08:40.000000000 +0200
+++ new/libimobiledevice-1.4.0+9git.20260610/tools/idevicebackup2.c     
2026-06-10 09:51:55.000000000 +0200
@@ -29,6 +29,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <errno.h>
+#include <stdarg.h>
 #include <stdlib.h>
 #include <signal.h>
 #include <unistd.h>
@@ -662,6 +663,193 @@
        lockdownd_client_free(lockdown);
 }
 
+/* ANSI escape codes for cursor manipulation */
+#define CURSOR_UP       "\033[1A"
+#define CURSOR_DOWN     "\033[1B"
+#define CURSOR_SAVE     "\033[s"
+#define CURSOR_RESTORE  "\033[u"
+#define CURSOR_HIDE     "\033[?25l"
+#define CURSOR_SHOW     "\033[?25h"
+#define CLEAR_LINE      "\033[2K"
+#define MOVE_COL_1      "\r"
+
+#define TRANSFER_NONE 0
+#define TRANSFER_SEND 1
+#define TRANSFER_RECEIVE 2
+
+/* Progress state - 4-line reserved area display */
+static double overall_progress = 0;
+static double file_progress = 0;
+static uint64_t file_current = 0;
+static uint64_t file_total = 0;
+static int transfer_status = 0;
+static int progress_mode_active = 0;
+static char progress_status[256] = "";
+static char transfer_info[256] = "";
+
+static void draw_progress_bar(double percent, int width)
+{
+       int i;
+       double ratio = width / 100.0;
+       printf("[");
+       for (i = 0; i < width; i++) {
+               if (i < (int)(percent * ratio)) {
+                       printf("#");
+               } else {
+                       printf(".");
+               }
+       }
+       printf("]");
+}
+
+static void draw_transfer_bar(double percent, int width)
+{
+       int i;
+       int pos = (int)((percent / 100.0) * width);
+
+       if (pos >= width)
+               pos = width - 1;
+       if (pos < 0)
+               pos = 0;
+
+       printf("[");
+       for (i = 0; i < width; i++) {
+               if (percent >= 100.0) {
+                       printf("=");
+               } else if (i < pos) {
+                       printf("=");
+               } else if (i == pos) {
+                       printf(">");
+               } else {
+                       printf(" ");
+               }
+       }
+       printf("]");
+}
+
+/* Initialize the 4-line progress area */
+static void progress_init(void)
+{
+       if (!progress_mode_active) {
+               progress_mode_active = 1;
+               /* Use current line as line 1, and reserve 3 more lines */
+               printf("\n\n\n");
+               /* Save cursor position at line 4 */
+               printf(CURSOR_SAVE);
+               progress_status[0] = '\0';
+               transfer_info[0] = '\0';
+       }
+}
+
+/* Render the 4-line progress display using current global state */
+static void progress_render(void)
+{
+       const int bar_width = 30;
+       const char *direction_label = "Sending";
+       const char *display_name = transfer_info;
+       if (!progress_mode_active) {
+               progress_init();
+       }
+
+       /* Restore saved cursor position for line 4, then move to line 1 */
+       printf(CURSOR_RESTORE);
+       printf(CURSOR_UP CURSOR_UP CURSOR_UP);
+
+       if (transfer_status == TRANSFER_RECEIVE) {
+               direction_label = "Receiving";
+       } else if (transfer_status == TRANSFER_SEND) {
+               direction_label = "Sending";
+       } else {
+               direction_label = "";
+       }
+
+       /* Line 1: Overall backup progress */   
+       printf(CLEAR_LINE MOVE_COL_1);
+       printf("%-10s ", "Backup");
+       draw_progress_bar(overall_progress, bar_width);
+       printf(" %3.0f%%", overall_progress);
+
+       /* Line 2: Current file */
+       printf("\n");
+       printf(CLEAR_LINE MOVE_COL_1);
+       printf("%-10s ", direction_label);
+       if (display_name[0]) {
+               //printf("%s%s", direction_arrow, display_name);
+               printf("%s", display_name);
+       }
+
+       /* Line 3: Sending / Receiving progress */
+       printf("\n");
+       printf(CLEAR_LINE MOVE_COL_1);
+       printf("%-10s ", "");
+       draw_transfer_bar(file_progress, bar_width);
+       printf(" %5.1f%%", file_progress);
+       if (file_current > 0 || file_total > 0) {
+               char *format_size_current = string_format_size(file_current);
+               char *format_size_total = string_format_size(file_total);
+               if (format_size_current && format_size_total) {
+                       printf("   %s / %s", format_size_current, 
format_size_total);
+               }
+               free(format_size_current);
+               free(format_size_total);
+       }
+       printf("     ");
+
+       /* Line 4: Status message */
+       printf("\n");
+       printf(CLEAR_LINE MOVE_COL_1);
+       printf("%-10s ", "Status");
+       if (progress_status[0]) {
+               printf("%s", progress_status);
+       }
+
+       /* Save cursor position at line 4 again for the next redraw */
+       printf(CURSOR_SAVE);
+       fflush(stdout);
+}
+
+/*
+ * Print a normal log line without permanently corrupting the reserved
+ * 4-line progress area. If progress mode is active, print the log message
+ * below the progress block, reserve a fresh 4-line area there, and redraw.
+ */
+static void progress_printf(const char *fmt, ...)
+{
+       va_list ap;
+
+       if (progress_mode_active) {
+               /* Go to saved line 4 and move to a fresh line below the block 
*/
+               printf(CURSOR_RESTORE);
+               printf("\n");
+       }
+
+       va_start(ap, fmt);
+       vprintf(fmt, ap);
+       va_end(ap);
+
+       if (progress_mode_active) {
+               /*
+                * Re-anchor the progress block on the current line:
+                * current line becomes line 1, plus 3 reserved lines below it.
+                */
+               printf("\n\n\n");
+               printf(CURSOR_SAVE);
+               progress_render();
+       }
+}
+
+#if 0
+/* Update progress values and render */
+static void progress_update(double overall, double file, uint64_t current, 
uint64_t total)
+{
+       overall_progress = overall;
+       file_progress = file;
+       file_current = current;
+       file_total = total;
+       progress_render();
+}
+
+/* Legacy single-line progress for simple operations */
 static void print_progress_real(double progress, int flush)
 {
        int i = 0;
@@ -677,42 +865,55 @@
 
        if (flush > 0) {
                fflush(stdout);
-               if (progress == 100)
-                       PRINT_VERBOSE(1, "\n");
+       }
+       if (progress == 100) {
+               PRINT_VERBOSE(1, "\n");
        }
 }
+#endif
 
-static void print_progress(uint64_t current, uint64_t total)
+/* Called during file transfers - uses 3-line display */
+static void print_progress(uint64_t current, uint64_t total, int sending)
 {
-       char *format_size = NULL;
-       double progress = ((double)current/(double)total)*100;
-       if (progress < 0)
-               return;
-
-       if (progress > 100)
-               progress = 100;
-
-       print_progress_real((double)progress, 0);
-
-       format_size = string_format_size(current);
-       PRINT_VERBOSE(1, " (%s", format_size);
-       free(format_size);
-       format_size = string_format_size(total);
-       PRINT_VERBOSE(1, "/%s)     ", format_size);
-       free(format_size);
-
-       fflush(stdout);
-       if (progress == 100)
-               PRINT_VERBOSE(1, "\n");
+       //double file_progress = 0;
+       /* Don't update file progress if overall backup is complete */
+       //if (overall_progress >= 100.0)
+       //      return;
+       file_current = current;
+       file_total = total;
+       if (total > 0) {
+               file_progress = ((double)current / (double)total) * 100;
+               if (file_progress > 100) file_progress = 100;
+       } else {
+               file_progress = 0;
+       }
+       //progress_update(overall_progress, file_progress, current, total);
+       transfer_status = sending;
+       progress_render();
+}
+
+/* Exit progress mode - print final newline */
+static void progress_finish(void)
+{
+       if (progress_mode_active) {
+               overall_progress = 100;
+               //transfer_status = TRANSFER_NONE;
+               progress_render();
+               progress_mode_active = 0;
+               printf("\n");
+               fflush(stdout);
+               progress_status[0] = '\0';
+               //transfer_info[0] = '\0';
+       }
 }
 
-static double overall_progress = 0;
-
+#if 0
 static void mb2_set_overall_progress(double progress)
 {
        if (progress > 0.0)
                overall_progress = progress;
 }
+#endif
 
 static void mb2_set_overall_progress_from_message(plist_t message, char* 
identifier)
 {
@@ -731,7 +932,8 @@
 
        if (node != NULL) {
                plist_get_real_val(node, &progress);
-               mb2_set_overall_progress(progress);
+               //mb2_set_overall_progress(progress);
+               overall_progress = progress;
        }
 }
 
@@ -822,16 +1024,17 @@
 #endif
        {
                if (errno != ENOENT)
-                       printf("%s: stat failed on '%s': %d\n", __func__, 
localfile, errno);
+                       progress_printf("%s: stat failed on '%s': %d\n", 
__func__, localfile, errno);
                errcode = errno;
                goto leave;
        }
 
        total = fst.st_size;
 
-       char *format_size = string_format_size(total);
-       PRINT_VERBOSE(1, "Sending '%s' (%s)\n", path, format_size);
-       free(format_size);
+       //char *format_size = string_format_size(total);
+       snprintf(transfer_info, sizeof(transfer_info), "%s", path); //"'%s' 
(%s)", path, format_size);
+       //free(format_size);
+       progress_render();
 
        if (total == 0) {
                errcode = 0;
@@ -840,7 +1043,7 @@
 
        f = fopen(localfile, "rb");
        if (!f) {
-               printf("%s: Error opening local file '%s': %d\n", __func__, 
localfile, errno);
+               progress_printf("%s: Error opening local file '%s': %d\n", 
__func__, localfile, errno);
                errcode = errno;
                goto leave;
        }
@@ -863,7 +1066,7 @@
                /* send file contents */
                size_t r = fread(buf, 1, sizeof(buf), f);
                if (r <= 0) {
-                       printf("%s: read error\n", __func__);
+                       progress_printf("%s: read error\n", __func__);
                        errcode = errno;
                        goto leave;
                }
@@ -872,10 +1075,11 @@
                        goto leave_proto_err;
                }
                if (bytes != (uint32_t)r) {
-                       printf("Error: sent only %d of %d bytes\n", bytes, 
(int)r);
+                       progress_printf("Error: sent only %d of %d bytes\n", 
bytes, (int)r);
                        goto leave_proto_err;
                }
                sent += r;
+               print_progress(sent, total, 1);
        } while (sent < total);
        fclose(f);
        f = NULL;
@@ -905,10 +1109,10 @@
                slen += length;
                err = mobilebackup2_send_raw(mobilebackup2, (const char*)buf, 
slen, &bytes);
                if (err != MOBILEBACKUP2_E_SUCCESS) {
-                       printf("could not send message\n");
+                       progress_printf("could not send message\n");
                }
                if (bytes != slen) {
-                       printf("could only send %d from %d\n", bytes, slen);
+                       progress_printf("could only send %d from %d\n", bytes, 
slen);
                }
        }
 
@@ -931,6 +1135,8 @@
        plist_t files = plist_array_get_item(message, 1);
        cnt = plist_array_get_size(files);
 
+       //snprintf(progress_status, sizeof(progress_status), "Sending files");
+
        for (i = 0; i < cnt; i++) {
                plist_t val = plist_array_get_item(files, i);
                if (plist_get_node_type(val) != PLIST_STRING) {
@@ -985,7 +1191,7 @@
                }
                if (nlen > 4096) {
                        // filename length is too large
-                       printf("ERROR: %s: too large filename length (%d)!\n", 
__func__, nlen);
+                       progress_printf("ERROR: %s: too large filename length 
(%d)!\n", __func__, nlen);
                        return 0;
                }
 
@@ -999,7 +1205,7 @@
                rlen = 0;
                mobilebackup2_receive_raw(mobilebackup2, *filename, nlen, 
&rlen);
                if (rlen != nlen) {
-                       printf("ERROR: %s: could not read filename\n", 
__func__);
+                       progress_printf("ERROR: %s: could not read filename\n", 
__func__);
                        return 0;
                }
 
@@ -1040,17 +1246,24 @@
                plist_get_uint_val(node, &backup_total_size);
        }
        if (backup_total_size > 0) {
-               PRINT_VERBOSE(1, "Receiving files\n");
+               //progress_printf("Receiving files\n");
+               snprintf(progress_status, sizeof(progress_status), "Receiving 
files");  /* Clear status when starting file transfers */
+               //transfer_info[0] = '\0';    /* Clear transfer info */
        }
 
        do {
                if (quit_flag)
                        break;
 
-               nlen = mb2_receive_filename(mobilebackup2, &dname);
+               nlen = mb2_receive_filename(mobilebackup2, &dname);     
                if (nlen == 0) {
                        break;
                }
+               if (nlen > 68) {
+                       snprintf(transfer_info, sizeof(transfer_info), "...%s", 
dname + (nlen - 65));
+               } else {
+                       snprintf(transfer_info, sizeof(transfer_info), "%s", 
dname);
+               }
 
                nlen = mb2_receive_filename(mobilebackup2, &fname);
                if (!nlen) {
@@ -1073,7 +1286,7 @@
                nlen = 0;
                mobilebackup2_receive_raw(mobilebackup2, (char*)&nlen, 4, &r);
                if (r != 4) {
-                       printf("ERROR: %s: could not receive code length!\n", 
__func__);
+                       progress_printf("ERROR: %s: could not receive code 
length!\n", __func__);
                        break;
                }
                nlen = be32toh(nlen);
@@ -1083,13 +1296,13 @@
 
                mobilebackup2_receive_raw(mobilebackup2, &code, 1, &r);
                if (r != 1) {
-                       printf("ERROR: %s: could not receive code!\n", 
__func__);
+                       progress_printf("ERROR: %s: could not receive code!\n", 
__func__);
                        break;
                }
 
                /* TODO remove this */
                if ((code != CODE_SUCCESS) && (code != CODE_FILE_DATA) && (code 
!= CODE_ERROR_REMOTE)) {
-                       PRINT_VERBOSE(1, "Found new flag %02x\n", code);
+                       progress_printf("Found new flag %02x\n", code);
                }
 
                remove_file(bname);
@@ -1115,7 +1328,7 @@
                                backup_real_size += blocksize;
                        }
                        if (backup_total_size > 0) {
-                               print_progress(backup_real_size, 
backup_total_size);
+                               print_progress(backup_real_size, 
backup_total_size, TRANSFER_RECEIVE);
                        }
                        if (quit_flag)
                                break;
@@ -1135,7 +1348,7 @@
                } else {
                        errcode = errno_to_device_error(errno);
                        errdesc = strerror(errno);
-                       printf("Error opening '%s' for writing: %s\n", bname, 
errdesc);
+                       progress_printf("Error opening '%s' for writing: %s\n", 
bname, errdesc);
                        break;
                }
                if (nlen == 0) {
@@ -1150,7 +1363,7 @@
                        msg[r] = 0;
                        /* If sent using CODE_FILE_DATA, end marker will be 
CODE_ERROR_REMOTE which is not an error! */
                        if (last_code != CODE_FILE_DATA) {
-                               fprintf(stdout, "\nReceived an error message 
from device: %s\n", msg);
+                               progress_printf("Received an error message from 
device: %s\n", msg);
                        }
                        free(msg);
                }
@@ -1161,7 +1374,7 @@
 
        /* if there are leftovers to read, finish up cleanly */
        if ((int)nlen-1 > 0) {
-               PRINT_VERBOSE(1, "\nDiscarding current data hunk.\n");
+               progress_printf("Discarding current data hunk.\n");
                fname = (char*)malloc(nlen-1);
                mobilebackup2_receive_raw(mobilebackup2, fname, nlen-1, &r);
                free(fname);
@@ -1425,7 +1638,9 @@
  */
 static void clean_exit(int sig)
 {
-       fprintf(stderr, "Exiting...\n");
+       snprintf(progress_status, sizeof(progress_status), "Abort requested, 
hold on...");
+       progress_render();
+       //fprintf(stderr, "Exiting...\n");
        quit_flag++;
 }
 
@@ -2303,6 +2518,8 @@
                                        /* device wants to download files from 
the computer */
                                        
mb2_set_overall_progress_from_message(message, dlmsg);
                                        mb2_handle_send_files(mobilebackup2, 
message, backup_directory);
+                       //snprintf(progress_status, sizeof(progress_status), 
"Waiting for device...");
+                       //progress_render();
                                } else if (!strcmp(dlmsg, 
"DLMessageUploadFiles")) {
                                        /* device wants to send files to the 
computer */
                                        
mb2_set_overall_progress_from_message(message, dlmsg);
@@ -2342,7 +2559,8 @@
                                        
mb2_set_overall_progress_from_message(message, dlmsg);
                                        plist_t moves = 
plist_array_get_item(message, 1);
                                        uint32_t cnt = 
plist_dict_get_size(moves);
-                                       PRINT_VERBOSE(1, "Moving %d file%s\n", 
cnt, (cnt == 1) ? "" : "s");
+                                       snprintf(progress_status, 
sizeof(progress_status), "Moving %d file%s", cnt, (cnt == 1) ? "" : "s");
+                                       progress_render();
                                        plist_dict_iter iter = NULL;
                                        plist_dict_new_iter(moves, &iter);
                                        errcode = 0;
@@ -2393,7 +2611,8 @@
                                        
mb2_set_overall_progress_from_message(message, dlmsg);
                                        plist_t removes = 
plist_array_get_item(message, 1);
                                        uint32_t cnt = 
plist_array_get_size(removes);
-                                       PRINT_VERBOSE(1, "Removing %d 
file%s\n", cnt, (cnt == 1) ? "" : "s");
+                                       snprintf(progress_status, 
sizeof(progress_status), "Removing %d file%s", cnt, (cnt == 1) ? "" : "s");
+                                       progress_render();
                                        uint32_t ii = 0;
                                        errcode = 0;
                                        errdesc = NULL;
@@ -2520,9 +2739,10 @@
                                if ((overall_progress > 0) && 
!progress_finished) {
                                        if (overall_progress >= 100.0F) {
                                                progress_finished = 1;
+                                               //progress_finish();
+                                       //} else {
+                                       //      
print_progress_real(overall_progress, 0);
                                        }
-                                       print_progress_real(overall_progress, 
0);
-                                       PRINT_VERBOSE(1, " Finished\n");
                                }
 
 files_out:
@@ -2547,6 +2767,8 @@
                        plist_free(message);
                        free(dlmsg);
 
+                       progress_finish();
+
                        /* report operation status to user */
                        switch (cmd) {
                                case CMD_CLOUD:

Reply via email to