pwman

Check-in [84a89d1e8e]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Avoid getting stuck in a loop when moving items I have a habit of hitting m instead of M and then getting stuck in a loop of "Sublist does not exist, try again" because there is no sublist I can move to. Although the code is meant to allow you to break out of this by pressing return (the answer[0] bit) it doesn't work for me (perhaps because of the changes I made on ui_statusline_ask_str that restore values on return?). So instead of running it in a loop, just run it once on keypress - it's not exactly a hassle to run it again if I do actually want to move an item and type it wrong.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/tweaks | trunk
Files: files | file ages | folders
SHA3-256: 84a89d1e8e9c0105121a87e7d631dcbb7ec9a3b12430a6b447d816563f9963eb
User & Date: base@atomicules.co.uk 2014-05-13 20:40:55
Context
2014-05-15
22:23
Merge branch 'manualheaven' into tweaks Leaf check-in: 91957153ef user: base@atomicules.co.uk tags: origin/tweaks, trunk
2014-05-13
20:40
Avoid getting stuck in a loop when moving items I have a habit of hitting m instead of M and then getting stuck in a loop of "Sublist does not exist, try again" because there is no sublist I can move to. Although the code is meant to allow you to break out of this by pressing return (the answer[0] bit) it doesn't work for me (perhaps because of the changes I made on ui_statusline_ask_str that restore values on return?). So instead of running it in a loop, just run it once on keypress - it's not exactly a hassle to run it again if I do actually want to move an item and type it wrong. check-in: 84a89d1e8e user: base@atomicules.co.uk tags: origin/tweaks, trunk
2014-01-06
11:10
Work-around for segfault & data corruption when secring is not available A couple of things here: 1) I probably use PWMan in a way that wasn't intended: I only make my secret key available to in temporarily, once authorised I delete the secring.gpg file entirely so it isn't hanging about on a machine. So when it times out I need to remember to copy my key back to the machine before I try to re-authorise. Sometimes I forget and ... 2) It seems that for reasons I don't have the inclination or ability to figure out, PWMan segfaults on exit when the secring.gpg isn't available or is 0 bytes (or, probably, doesn't contain the required secret key). This on it's own isn't a bad thing, but when it does this it also seems to have a nasty habit of corrupting the password database; not always in an immediately obvious manner so I can end up "backing up" this corrupted version. So as a workaround (for my usage circumstances), this fix checks whether the secring file is 0 bytes and if it is waits until it isn't (I.e. I've copied it back to the machine) before asking for re-authorisation. This isn't perfect as it only waits once. I.e. if it recognises the secring is available it'll prompt for the password, but it is possible that in this time I could get distracted and come back after the secring file is removed again (since I remove it automatically) and forget and cause a segfault, but then I've only my stupid self to blame. check-in: 58b6e98d51 user: base@atomicules.co.uk tags: origin/tweaks, trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/actions.c.

515
516
517
518
519
520
521

522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541

542
543


544
545

546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569

570
571


572
573

574
575
576
577
578
579
580
action_list_move_item()
{
	Pw* curpw;
	PWList *curpwl, *iter;
	int i;
	char str[STRING_LONG];
	char answer[STRING_MEDIUM];


	switch(uilist_get_highlighted_type()){
		case PW_ITEM:
			curpw = uilist_get_highlighted_item();
			if(curpw){
				while(1){
					snprintf(str, STRING_LONG, "Move \"%s\" to where?", curpw->name);
					ui_statusline_ask_str(str, answer, STRING_MEDIUM);
					
					/* if user just enters nothing do nothing */
					if(answer[0] == 0){
						return 0;
					}
					
					for(iter = current_pw_sublist->sublists; iter != NULL; iter = iter->next){
						if( strcmp(iter->name, answer) == 0 ){
							pwlist_detach_pw(current_pw_sublist, curpw);
							pwlist_add_ptr(iter, curpw);
							uilist_refresh();
							return 0;

						}
					}


					ui_statusline_msg("Sublist does not exist, try again");
					getch();

				}
			}
			break;
		case PW_SUBLIST:
			curpwl = uilist_get_highlighted_sublist();
			if(curpwl){
				while(1){
					snprintf(str, STRING_LONG, "Move sublist \"%s\" to where?", curpwl->name);
					ui_statusline_ask_str(str, answer, STRING_MEDIUM);
					
					/* if user just enters nothing, do nothing */
					if(answer[0] == 0){
						return 0;
					}
					if( strcmp(answer, curpwl->name) == 0 ){
						return 0;
					}

					for(iter = current_pw_sublist->sublists; iter != NULL; iter = iter->next){
						if( strcmp(iter->name, answer) == 0 ){
							pwlist_detach_sublist(current_pw_sublist, curpwl);
							pwlist_add_sublist(iter, curpwl);
							uilist_refresh();
							return 0;

						}
					}


					ui_statusline_msg("Sublist does not exist, try again");
					getch();

				}
			}
			break;
		case PW_UPLEVEL:
		case PW_NULL:
		default:
			/* do nothing */







>





|
|
|
|
<
<
<
<
<
|
|
|
|
|
<
>
|
|
>
>


>






|
|
|
|
<
<
<
<
<
<
<
<
|
|
|
|
|
<
>
|
|
>
>


>







515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531





532
533
534
535
536

537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554








555
556
557
558
559

560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
action_list_move_item()
{
	Pw* curpw;
	PWList *curpwl, *iter;
	int i;
	char str[STRING_LONG];
	char answer[STRING_MEDIUM];
	int sublistfound;

	switch(uilist_get_highlighted_type()){
		case PW_ITEM:
			curpw = uilist_get_highlighted_item();
			if(curpw){
				sublistfound = 0;
				snprintf(str, STRING_LONG, "Move \"%s\" to where?", curpw->name);
				ui_statusline_ask_str(str, answer, STRING_MEDIUM);
				





				for(iter = current_pw_sublist->sublists; iter != NULL; iter = iter->next){
					if( strcmp(iter->name, answer) == 0 ){
						pwlist_detach_pw(current_pw_sublist, curpw);
						pwlist_add_ptr(iter, curpw);
						uilist_refresh();

						sublistfound = 1;
					}
				}
				/* then only do this if not found */
				if ( sublistfound == 0 ){
					ui_statusline_msg("Sublist does not exist, try again");
					getch();
					ui_statusline_clear();
				}
			}
			break;
		case PW_SUBLIST:
			curpwl = uilist_get_highlighted_sublist();
			if(curpwl){
				sublistfound = 0;
				snprintf(str, STRING_LONG, "Move sublist \"%s\" to where?", curpwl->name);
				ui_statusline_ask_str(str, answer, STRING_MEDIUM);
				








				for(iter = current_pw_sublist->sublists; iter != NULL; iter = iter->next){
					if( strcmp(iter->name, answer) == 0 ){
						pwlist_detach_sublist(current_pw_sublist, curpwl);
						pwlist_add_sublist(iter, curpwl);
						uilist_refresh();

						sublistfound = 1;
					}
				}
				/* then only do this if not found */
				if ( sublistfound == 0 ){
					ui_statusline_msg("Sublist does not exist, try again");
					getch();
					ui_statusline_clear();
				}
			}
			break;
		case PW_UPLEVEL:
		case PW_NULL:
		default:
			/* do nothing */