# K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage)

# ---------- Macro Compatibility -----------------------------------------------------------------------------------
#
# Dependencies	: main.kmm ($KM_Version), groups.kmm (Preferences)
# Resources	: -
# Preferences	: -
#
# ------------------------------------------------------------------------------------------------------------------

# ----- PRIVATE
___migratePrefs{
$___msg="";
&___checkGroups;
$___msg==""?0:alert(sub("%1",$KM_Version,_("Your profile was created by a version prior to K-Meleon %1. The following data has been updated:"))."\n".$___msg."\n\n"._("Please restart K-Meleon."),sub("%1",$KM_Version,_("Welcome to K-Meleon %1 !")));
setpref(BOOL,$macroPrefBranch."modules.compat.load",false);
}
$OnLoadOnce=$OnLoadOnce."___migratePrefs;";

# Groups
$___groupnames="kmeleon.groupnames";
$___groupbranch="kmeleon.group.";
___checkGroups{
getpref(STRING,$___groupnames)==""?0:&___migrateGroups;
}
___migrateGroups{
$__groups=getpref(STRING,$___groupnames);
getpref(STRING,$_Groups_Pref)==""?setpref(STRING,$_Groups_Pref,$__groups):$__groups="";
$__groups==""?0:$___msg=$___msg."\n"._("Groups");
$__groups=sub("\n","",$__groups);
while($__groups) &___migrateGroupsLoop;
}
___migrateGroupsLoop{
$__group=substr($__groups,0,index($__groups,"\n"));
setpref(STRING,$_Groups_UserPrefBranch.$__group,getpref(STRING,$___groupbranch.$__group));
$__groups=sub($__group."\n","",$__groups);
}

# Layers to Tabs
___checkLayers{
$__pref="kmeleon.general"; &___migrateLayers;
$__pref="kmeleon.plugins.bookmarks"; &___migrateLayers;
$__pref="kmeleon.plugins.favorites"; &___migrateLayers;
$__pref="kmeleon.plugins.hotlist"; &___migrateLayers;
$__pref="kmeleon.plugins.macros.selected"; &___migrateLayers;
setpref(STRING,"kmeleon.general.opengroup",$kTabs?"ID_OPEN_LINK_IN_NEW_TAB|ID_OPEN_LINK_IN_BACKGROUNDTAB":"ID_OPEN_LINK|ID_OPEN_LINK_IN_BACKGROUND");
}
___migrateLayers{
$__data=getpref(STRING,$__pref.".openurl");
$__data=="layers(OpenURL)"?setpref(STRING,$__pref.".openurl","ID_OPEN_LINK_IN_NEW_TAB"):0;
$__data=="layers(OpenURLBg)"?setpref(STRING,$__pref.".openurl","ID_OPEN_LINK_IN_BACKGROUNDTAB"):0;
}