Confused about displayKey, displayVersion (and displayValue)

Asked by dwood

I'm confused about this line in the release notes for 1.5b5:

"The feedParametersForUpdater: delegate method now requires displayKey and displayVersion keys so that it can inform the user what’s being sent."

So this is what I was doing, in order to make my feed's URL have parameters like type=beta&appname=Sandvox&version=7782 appended to the feed URL so that my server can generate the appropriate appcast feed.

This is what my delegate's definition of feedParametersForUpdater:sendingSystemProfile: has been. (I'm ignoring the sendingProfile value; that doesn't really affect what URL I want to send to my server.)

- (NSArray *)feedParametersForUpdater:(SUUpdater *)updater sendingSystemProfile:(BOOL)sendingProfile;
{
 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
 NSString *feedType = [defaults objectForKey:@"KSFeedType"];
 if (nil == feedType)
 {
  feedType = @"";
 }
 NSDictionary *feedTypeDict = [NSDictionary dictionaryWithObjectsAndKeys:
          @"type", @"key",
          feedType, @"value", nil];

 NSDictionary *appDict = [NSDictionary dictionaryWithObjectsAndKeys:
        @"appname", @"key",
        [NSApplication applicationName], @"value",
        nil];

 NSDictionary *versDict = [NSDictionary dictionaryWithObjectsAndKeys:
         @"version", @"key",
         [NSApplication buildVersion], @"value",
         nil];

 NSArray *feedParams = [NSArray arrayWithObjects:appDict, versDict, feedTypeDict, nil];
 return feedParams;
}

So now there's the mention of 'displayKey' and 'displayVersion' ... and I'm trying to understand how they are used and where I'm supposed to put them. There's also 'displayValue' which SUUpdatePermissionPrompt.nib seems to be using, but isn't mentioned here. Can you explain where these strings need to be inserted? I'm guessing you want another tuple inserted into each of those dictionaries like @"Application Name", @"displayKey", but where would the others go?

And I suppose it's OK if this inserts additional query parameters to the URL I send to my server but it's really confusing what you are intending. Thanks for any clarification you can add!

Question information

Language:
English Edit question
Status:
Answered
For:
Sparkle Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Andy Matuschak (andymatuschak) said :
#1

Aha! You should be confused. It was supposed to be "displayKey" and "displayValue" (not "displayVersion"); these are displayed to the user in the initial prompt. For instance, displayKey would be something like "How many nuclear-powered kittens are installed?" and displayValue would be "49, and 3 with jet packs." Basically, they're just human-readable keys. I'll update the blog post to be more helpful.

Revision history for this message
Hofman (cmhofman) said :
#2

I think you should add some code to default the displayKey/displayValue to key/value if they're not supplied.

Revision history for this message
dwood (dwood-karelia) said :
#3

Um, OK, I'm getting closer. Though your particular examples aren't very good because it's not likely I'm going to be sending parameters about nuclear powered kittens to my web server.

Maybe part of the confusion is that I'm using this method to build up the URL to pass to my server to get the appcast. So why is there something about keys and values that are "displayed to the user in the initial prompt". (What initial prompt?)

Should there perhaps be *two* delegate methods, one to build up the URL, and the new one to do whatever it is you are trying to accomplish with these new keys?

If you had some more concrete examples, perhaps using the key/values that I gave in my question as a launching point [NO PUN INTENDED, MEOW] that would be helpful. Thanks!

Revision history for this message
Hofman (cmhofman) said :
#4

They're just keys in addition to key/value, e.g.

NSDictionary *appDict = [NSDictionary dictionaryWithObjectsAndKeys:
        @"appname", @"key",
        [NSApplication applicationName], @"value",
        @"Application Name", @"displayKey",
        [NSApplication applicationNameForDisplay], @"displayValue",
        nil];

And why bother having two delegate methods when one can do?

The initial prompt is the SUUpdatePermissionPrompt that Sparkle may show at the second launch to ask whether the user wants to allow automatic update checking. It may also display a list of feed parameters that is send along, so the user may decide it may allow this (or not). It uses displayKey/displayValue for that.

Revision history for this message
dwood (dwood-karelia) said :
#5

Really there should be two methods because they do two separate things. I don't want to put extra keys into the URLs that I'm sending to my server...

Revision history for this message
Andy Matuschak (andymatuschak) said :
#6

If it were two methods, associating the key/value pairs from each would require extra meta-info. I think that'd be a much uglier solution.

Can you help with this problem?

Provide an answer of your own, or ask dwood for more information if necessary.

To post a message you must log in.