diary

Text-based journaling program
git clone https://git.in0rdr.ch/diary.git
Log | Files | Refs | README | LICENSE

commit 7b397c403d6a2f1e024a18257ca5cc00bee2441a
parent 73afa544980beac31b382fe9d59e078dde4af5cd
Author: Andreas Gruhler <agruhl@gmx.ch>
Date:   Sun, 16 Jan 2022 22:51:03 +0100

feat(caldav): fix unit value & remove msg

Diffstat:
Msrc/caldav.c | 34+++++++---------------------------
Msrc/diary.c | 2+-
2 files changed, 8 insertions(+), 28 deletions(-)

diff --git a/src/caldav.c b/src/caldav.c @@ -31,7 +31,7 @@ static size_t curl_write_mem_callback(void * contents, size_t size, size_t nmemb char* ptr = realloc(mem->memory, mem->size + realsize + 1); if (!ptr) { - fprintf(stderr, "not enough memory (realloc in CURLOPT_WRITEFUNCTION returned NULL)\n"); + fprintf(stderr, "Error - not enough memory (realloc in CURLOPT_WRITEFUNCTION returned NULL)\n"); return 0; } @@ -184,7 +184,6 @@ void get_access_token(char* code, char* verifier, bool refresh) { ipstr, GOOGLE_OAUTH_REDIRECT_PORT); } - fprintf(stderr, "CURLOPT_POSTFIELDS: %s\n", postfields); curl = curl_easy_init(); @@ -212,7 +211,7 @@ void get_access_token(char* code, char* verifier, bool refresh) { curl_easy_cleanup(curl); if (res != CURLE_OK) { - fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res)); + fprintf(stderr, "Error - curl_easy_perform() failed: %s\n", curl_easy_strerror(res)); return; } // update global variables from tokenfile @@ -732,9 +731,6 @@ int caldav_sync(struct tm* date, // to attempt to determine whether DST is in effect at the specified time localfile_time->tm_isdst = -1; time_t localfile_date = mktime(localfile_time); - fprintf(stderr, "Local dst: %i\n", localfile_time->tm_isdst); - fprintf(stderr, "Local file last modified time: %s\n", ctime(&localfile_date)); - // fprintf(stderr, "Local file last modified time: %s\n", ctime(&attr.st_mtime)); struct tm remote_datetime; time_t remote_date; @@ -748,14 +744,9 @@ int caldav_sync(struct tm* date, // remote file does probably not exist, set remote date to 1970 remote_date = epoch_zero; } else { - fprintf(stderr, "Remote last modified: %s\n", remote_last_mod); - fprintf(stderr, "Remote UID: %s\n", remote_uid); strptime(remote_last_mod, "%Y%m%dT%H%M%SZ", &remote_datetime); remote_datetime.tm_isdst = -1; - fprintf(stderr, "Remote dst: %i\n", remote_datetime.tm_isdst); remote_date = mktime(&remote_datetime); - fprintf(stderr, "Remote dst: %i\n", remote_datetime.tm_isdst); - fprintf(stderr, "Remote last modified: %s\n", ctime(&remote_date)); free(remote_last_mod); free(remote_uid); } @@ -776,18 +767,7 @@ int caldav_sync(struct tm* date, free(event); return 0; } else if (timediff > 0) { - // local time > remote time - // if local file mod time more recent than LAST-MODIFIED - - // if (remote_last_mod == NULL || remote_uid == NULL) { - // // purge any existing daily calendar entries on the remote side - // char event_uri[300]; - // sprintf(event_uri, "%s%s%s.ics", GOOGLE_API_URI, calendar_href, remote_uid); - - // caldav_req(date, event_uri, "DELETE", "", 0); - // } - - fputs("Local file is newer, uploading to remote...\n", stderr); + fputs("Info - Local file is newer. Uploading to remote.\n", stderr); put_event(date, dir, dir_size, uri); pthread_cancel(progress_tid); @@ -795,10 +775,9 @@ int caldav_sync(struct tm* date, } else if (timediff < 0) { rmt_desc = extract_ical_field(event, "DESCRIPTION", &search_pos, true); - fprintf(stderr, "Remote event description:%s\n", rmt_desc); if (rmt_desc == NULL) { - fprintf(stderr, "Could not fetch description of remote event.\n"); + fprintf(stderr, "Error - Could not fetch description of remote event. Aborting sync.\n"); pthread_cancel(progress_tid); wclear(header); return -1; @@ -819,7 +798,7 @@ int caldav_sync(struct tm* date, conf_ch = wgetch(header); if (conf_ch == 'y' || conf_ch == 'Y' || conf_ch == 'a' || conf_ch == '\n' || !confirm) { - fprintf(stderr, "Remote file is newer, extracting description from remote...\n"); + fprintf(stderr, "Info - Remote file is newer. Extracting description from remote.\n"); // persist downloaded buffer to local file FILE* cursordate_file = fopen(path, "wb"); @@ -859,4 +838,4 @@ int caldav_sync(struct tm* date, // free memory allocated to store curl response free(event); return conf_ch; -} +} +\ No newline at end of file diff --git a/src/diary.c b/src/diary.c @@ -585,7 +585,7 @@ int main(int argc, char** argv) { keypad(cal, TRUE); draw_calendar(cal, aside, CONFIG.dir, strlen(CONFIG.dir)); - int ch, conf_ch; + int ch = 0, conf_ch = -1; int pad_pos = 0; int syear = 0, smonth = 0, sday = 0; char ics_filepath[256];